0

I am calling the function like so:

beta=NaN(size(rates,1),6);

mats=[1:50];

mats2=[2 5 10 30];

for i=1:2
y2=rates(i,mats2);
yM=rates(i,:);

dataList=struct('yM',yM,'mats',mats,'model',@NSS,'mats2',mats2,'y2',y2);

de=struct('min',[0;3.5],'max',[3.5;30],'d',2,'nP',200,'nG',600,'ww',0.1,'F',0.5,'CR',0.99,'R',0,'oneElementfromPm',1);


beta(i,:)=DElambdaVec(de,dataList,@OF);
end

However the output from DElabdavec, is a cell array:

output.Fbest=Fbest; output.xbest=xbest; output.Fbv=Fbv;

How can I store each of these items on each pass of the for loop?

1 Answer 1

1

You can save the results to a cell array - beta in this case:

beta{i} = DElambdaVec(de,dataList,@OF);

Every element of beta is now an object returned by DElambdaVec, e.g.:

beta{1}

ans = 

Fbest: 'Fbest'
xbest: 'xbest'
  Fbv: 'Fbv'

I used example values to create the entries here.

Note that you have to initialize beta=[] before the loop.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.