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

### Dalia Rashed (view profile)

on 16 Jun 2019
Latest activity Commented on by Matt J

### Matt J (view profile)

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

on 16 Jun 2019
Edited by Matt J

### Matt J (view profile)

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

Matt J

### Matt J (view profile)

on 16 Jun 2019
You could also use a struct array
S(1).config=X1
S(1).penalty=penalty1
...
S(N).config=XN
S(N).penalty=penaltyN
Dalia Rashed

### Dalia Rashed (view profile)

on 17 Jun 2019
thank you so much for your help.Matt J
Matt J

### Matt J (view profile)

on 17 Jun 2019
You're welcome, but please Accept-click the answer to indicate that it helped you.