i have to run .m file 51 times. how can i save all 51 results in one file?
Show older comments
The program contains 3 functions:
function algorithm code,
function bounds,
function problem code,
In result it creates a .mat file with 1 value. i have tried several options to do multiple runs with multiple outputs in 1 file like on every run it adds new value in file but it couldn't works .
Is there any way to solve this thing?
Accepted Answer
More Answers (1)
Geoff Hayes
on 7 Sep 2015
0 votes
Muhammad - try saving the results of each iteration to an array and then, once the last iteration has completed, write this array to the mat file.
4 Comments
Muhammad Umer
on 7 Sep 2015
Geoff Hayes
on 7 Sep 2015
Edited: Geoff Hayes
on 7 Sep 2015
Aren't you doing that already? Use a for loop to iterate over your three functions. Save the output at each iteration to an array and then, once you have exited the for loop, save the array to the file.
Muhammad Umer
on 7 Sep 2015
Geoff Hayes
on 7 Sep 2015
Edited: Geoff Hayes
on 7 Sep 2015
Muhammad - typically, the error
Maximum recursion limit of 500 reached.Use set(0,'RecursionLimit',N) to change the limit. Be aware that exceeding your available stack space can crash MATLAB and/or your computer.
indicates that a function is calling itself recursively (without a "stopping" condition). For example, the following code would generate the same error
function algorithm
algorithm
If the above is saved to a file called algorithm.m and then called from the command line, then we would observe the same error that you have described. Have you perhaps done something similar in your algorithm function?
As for the second error
Function definitions are not permitted in this context.
this generally happens if you write a function signature after you have already written some code within your script. For example, if the following is saved to a file called myScript.m
% some dummy code
t = 42;
function myFunction(a,b,c)
and then I try to execute the script, I would see the same error as you. Have you written something similar in your code?
Please post some or all of your code so that we can get an idea of what you have written and what can be done so that you can obtain the results that you desire.
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!