Running matlab files at other folders in Matlab
Ältere Kommentare anzeigen
Hello,
I want to write a matlab code to run multiple matlab .m files in another folder. In order to express my question clearly, I attached one example,
Now I have a matlab code called "upscalingMethod.m", I want it to run other .m files in another folder, its the content is as follows, I wrote a relative directory for the path and run regression.m file.
function f = UpscalingMethod
path = './folder/file';
run( path, 'regression('data.csv') );
end
The relative path of other matlab .m files is "./folder/file". These .m files all need to have some input arguments, here I only attached one regression.m file for convenience. For example, when I ran regression.m at its folder, I need to type in "regression('data.csv')" instead of "regression".
I ran the "upscalingMethod.m", but there are something wrong,
Can you help me?
Thank you so much.
2 Kommentare
per isakson
am 21 Aug. 2016
The second input argument of run shall be a character vector, but 'regression('data.csv') is not. (I corrected an obvious typo.)
Try replace
run( path, 'regression('data.csv') );
by
run( path, 'regression(''data.csv'')' );
Shuo Wang
am 21 Aug. 2016
Antworten (1)
Walter Roberson
am 21 Aug. 2016
0 Stimmen
2 Kommentare
Shuo Wang
am 21 Aug. 2016
Walter Roberson
am 21 Aug. 2016
run() can only be used for scripts. If you want to execute a function (not script) in another folder then you either need to manipulate your MATLAB path so that the other folder is on your path or you need to cd() to the other folder and execute the function from there.
Kategorien
Mehr zu Startup and Shutdown finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!