Effacer les filtres
Effacer les filtres

Converting third dimension of 3D matrix to 1xN object

2 vues (au cours des 30 derniers jours)
Joel Paprocki
Joel Paprocki le 8 Août 2018
Modifié(e) : Stephen23 le 9 Août 2018
Hello,
I have a 3D matrix, and I have been trying to use a loop to generate an object array with 1xN objects (all containing a few properties/fields). I have multiple images in a 3D matrix, each x and y are the images, and z is the number of images. I want to separate the each image into its own object so I can associate another field with each image. I have tried this, but it doesn't give me the object array...
Note that Struct.m is just where the properties lie...
A = randi(5, 4, 4, 5);
struct = Struct;
for ii = 1:size(A,3)
struct.Image = A(:,:,ii);
end
Any pointers? I believe this should be extremely simple, but I am doing something wrong with indices.
Please let me know, thank you all.

Réponses (1)

Thorsten
Thorsten le 8 Août 2018
struct(ii).Image = A(:,:,ii);

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by