Creating an automation script that will run a series of problems

2 次查看(过去 30 天)
I am trying to automate a run script. I have the script performing the actual calculations with all the functions in a directory called 'Source'. Then the files unique the problem such as geometry, boundary conditions, and initial conditions are in a directory for the specific problem (i.e 'Problem1', 'Problem2' through 'Problem6'). Additionally, there is a post processing script in each problem folder called post.m. I'm doing this so I dont have to keep switching folders and can run all six problems simulataneously.
I am having problems with the structure of the script though and am getting errors in 'run', which is a command I am using. Below is my automation script. Thanks for taking a look
for i = ['Problem1','Problem2','Problem3','Problem4','Problem5','Problem6']
addpath('C:\Users\me\Documents\GitHub\Project\Problems\i')
run('C:\Users\me\Documents\GitHub\Project\Source\run_analysis.m')
run('post.m')
end

采纳的回答

Jonas
Jonas 2021-6-27
编辑:Jonas 2021-6-27
your i will run through each character of your string you combined with your [ ] (like horzcat), it will be P, then r, then o and so on.
what you maybe want is
myPaths={'Problem1','Problem2','Problem3','Problem4','Problem5','Problem6'};
addpath('C:\Users\me\Documents\GitHub\Project\Source\');
for pathNr=1:6
cd(['C:\Users\me\Documents\GitHub\Project\Problems\' myPaths{pathNr}]);
run_analysis();
post();
end
using run() changes the directory to the file called and changes back after execution, so that's not that what you want here because you want to run the same code in each folder (?)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Search Path 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by