|
I tried to write matlab code in a modularized way, but I am not sure if it's correct, as compiler return error when I did the below:
main.m is the script which triggers multiple trial run of experiment.
algo.m contains the procedure to execute each experiment.
common.m contains utility function for file reading etc.
When I compiled at main.m, error returns
"Undefined function 'experiment' for input arguments of type 'char'."
May I know how to overcome the error, and is this the correct way to write modular matlab script?
**************
main.m which contains the below lines
----------------
R = experiment('t1_run.txt');
R = experiment('t2_run.txt');
R = experiment('t3_run.txt');
**************
algo.m which run each experiment
----------------
function ret = experiment(filepath)
% read data from file
D = read_data(filepath, '%.3f');
% run experiment step 1
% run experiment step 2
% run experiment step n
ret = 1;
return
----------------
**************
common.m which read files
----------------
function D = read_data(path, format)
fid = fopen(path,'r');
D = textscan(fid, format);
fclose(fid);
return
----------------
|