- You have the script main.m that has the paramters
- and a seperate matlab script project.m
- then you are trying to call project.m in the main.m to loop on it .
let a script run in other script with variable parameters
19 次查看(过去 30 天)
显示 更早的评论
I want to let a script (ex: project.m) run in other script (ex: main.m) with changing parameters.
It means, the parameters is set in the main.m script and the project.m is loaded from the main.m and runs in a for-loop with the defined parameters.
Thank you so much for your answer!
Best Regards,
Minyoung
2 个评论
Abderrahim. B
2022-7-4
Hi Minyoung ,
Correct me if i am mistaken .
Please clarify so we can provide you with answers!
采纳的回答
Abderrahim. B
2022-7-4
Hi Minyoung ,
You can run a matlab script inside another this way :
run('project.m')
A good practice is to create a function from your script project.m and call it then in you main:
Function project.m
function [outArg1, outArg2,..,outArgN] = project(inArg1, inArg2, ..,inArgN )
yourCodeHere
end
main.m
% parameters
% call your function
M = 10 ;
for ii = 1:M
[outArg1, outArg2,..,outArgN] = project(inArg1, inArg2, ..,inArgN ) ;
end
更多回答(1 个)
Jonas
2022-7-4
it really sounds like you actally should change your script to a fcuntion. Running a script giving paramters to it is exactly what a function is
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!