Hello!
I have a structure of five 3D images (double,size 181x213x41). I would like to create a cell from this data, of same size as the 3D images (181x213x41) where each element will be a vector of size 1×5. I.e. the first vector element comes from 3D image 1, the second element from 3D image 2 and so on.
Example:
cellImage{i,j,k} = [1 2 4 1 0];
where
structure(1).image(i,j,k) = 1structure(2).image(i,j,k) = 2structure(3).image(i,j,k) = 4structure(4).image(i,j,k) = 1structure(5).image(i,j,k) = 0
I can do this by looping:
for i = 1:5 for j = 1:181 for k = 1:213 for l = 1:41 cellImage{j,k,l}(i) = structure(i).image(j,k,l); end end endend
This takes a very long time however. I want something similar to below (but that doesn't work).
for i = 1:5 cellImage{:,:,:}(i) = structure(i).image(:,:,:);end
Does anyone know of a better way of doing this?
Thank you!
Best Answer