running x.m file many times. I want to store values separately.

1 view (last 30 days)
I am running x.m file 25 times repeatedly in one go. I want to store separately max and min values(operations in x.m file) of each iteration in matrix form in mat file. Can anyone suggest?
  6 Comments
N/A
N/A on 23 Oct 2018
Edited: N/A on 23 Oct 2018
Thank you. Actually I am taking max(profits) and I want to store this value so that on next iteration I can compare both max values and want to store maximum among them. So basically for one iteration it is 1x1 array and finally as a result I want maximum max value among all iterations but also want to store max of each iteration. I am facing problem in comparison as in mat file i am having only max value of last iteration which is not sufficient. Thank you again.
N/A
N/A on 23 Oct 2018
this image is for iteration=2;but it is storing only max value of iteration=2. instead of that i want to store and compare both max values. so i want this for each iteration.

Sign in to comment.

Accepted Answer

dpb
dpb on 23 Oct 2018
N=25; % or whatever max number is
n=5; % or whatever number observations/iteration is
p=zeros(N,n); % holding array for the results of N iterations w/ n results/iteration
for i=1:N
for j=1:n
p(i,j)=x(....); % each call to the function returns one profit value???
end
end
[mxpgen,ixgen]=max(p,[],2); % max of each generation by iteration and which generation
[mxptot,ixtot]=max(mxpgen); % max overall and which iteration contained it
If you modify x to operate in vector sense, it could return the first result itself.
  5 Comments
N/A
N/A on 24 Oct 2018
without your help it won't be possible. really thank you. :)

Sign in to comment.

More Answers (0)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Products


Release

R2014a

Community Treasure Hunt

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

Start Hunting!