Running matlab files at other folders in Matlab

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

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
Shuo Wang am 21 Aug. 2016
Hello,
Thank you for your help. I tried your method, but it still does not work. When I run it, the following error comes out,
Error using run Too many input arguments.
Error in UpscalingMethod (line 3) run( path, 'regression(''data.csv'')' );

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Walter Roberson
Walter Roberson am 21 Aug. 2016

0 Stimmen

2 Kommentare

Shuo Wang
Shuo Wang am 21 Aug. 2016
hello,
Thank you for your reply. I followed the instruction after clicking the link, but it does not work.
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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Startup and Shutdown finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 21 Aug. 2016

Kommentiert:

am 21 Aug. 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by