I have three matlab functions written (by function I mean an independent script that start with function and can be directly used in other matlab file) with names and inputs arguments like: Simulator_m1(folder,numberofparts)
Simulator_m2(folder,numberofparts)
Simulator_W(folder,numberofparts)
Since each simulator will run for a relatively long time so I want to have a file that is able to run them one by one together instead of me manually run then one by one in the command.
The only thing different for the input arguments is the folder which would be a string like "folder_m1" or "folder_m2". The number of different folders correspond to the number of function as the folder are used to store the simulation results.
I am thinking something like:
names = ['m1','m2', 'W'];
folders = ['m1','m2','W']
for i = 1:3
Simulator_names(i)(folders(i),numberofparts)
end
The code above are just to show my thoughts. I am not very familiar with handling this kind of work with matlab. I would like to hear any suggestions you can provides. Thank you in advance!
Jason
See if this is what you need. It uses feval
to call a function whose name is built at runtime.
names = {'m1','m2', 'W'};
folders = {'m1','m2','W'};
for n = 1:3
feval(['Simulator_' names{n}], ['folder_' folders{n}], numberofparts)
end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.