MATLAB Answers

0

how can i store the solution (3D mtarix) and its value for a population of N

Asked by Dalia Rashed on 16 Jun 2019
Latest activity Commented on by Matt J
on 17 Jun 2019
i have a population of N elements and each produce a certain solution configuration 3D matrix( for example solution X is X(:,:,1)=[1 2 3;4 5 6] and X(:,:,2)=[7 2 3;9 5 8]) this configuration results in an objective function or penalty function equals to 90) i need to store all the solution configurations for all the N population and the corresponding penalty function so that i'll report the best solution reached and its value&configuration. i need it to be fast. thank you

  0 Comments

Sign in to comment.

1 Answer

Answer by Matt J
on 16 Jun 2019
Edited by Matt J
on 16 Jun 2019

So the question is how to store a set of 3D matrices? Why not use a 4D matrix
Configs(:,:,:,1)=X1
Configs(:,:,:,2)=X2
...
Configs(:,:,:,N)=XN
or a cell array
Configs{1}=X1
Configs{2}=X2
...
Configs{N}=XN

  5 Comments

You could also use a struct array
S(1).config=X1
S(1).penalty=penalty1
...
S(N).config=XN
S(N).penalty=penaltyN
thank you so much for your help.Matt J
You're welcome, but please Accept-click the answer to indicate that it helped you.

Sign in to comment.