How to tell matlab to go to the next iteration of loop when loop started in different code file?
2 ビュー (過去 30 日間)
古いコメントを表示
Hey everyone,
I have written a matlab script that involves several different code files. There is one file containing a code that tells matlab to go through each and every one of my subcodes (that are saved in different files for example data_import.m, calculation.m, addition.m, comparison.m etc.). The name of this 'overall' file is whole_modell.m.
Now, whole_modell.m contains a loop. And I want to add an if-command in one of the subfiles (calculation.m) to tell matlab to go back to the loop in whole_modell.m and start with the next iteration instead of continueing through the rest of the present iteration.
Is there a way to do that??
Thanks a lot!
0 件のコメント
回答 (2 件)
Adam
2014 年 11 月 7 日
Just return a variable from calculation.m that determines whether to continue with the iteration or not and use that variable in your if statement in your main script/function.
0 件のコメント
Vipin Mohan
2014 年 11 月 7 日
Hi,
You can use a function declaration for the sub-functions(data_import.m, calculation.m) and save the sub-functions in the same folder as in the main function (whole_modell.m). The thumbnails of subfunctions are look different in the matlab environment. http://www.mathworks.com/help/matlab/ref/function.html So that you can distiguish betn them
I think you can use a 'return' syntax to go back to main program
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!