Reputation: 61
I am facing a problem doing some animation for a assignment in matlab
Let say that for instance I have a matrix 3D where the last index determine the color and the the others are determining the x,y,z coordinates.
a(:,:,1,1) =
0.9124 0.8790 0.8823
0.3242 0.7791 0.4257
0.2905 0.3944 0.4664
a(:,:,2,1) =
0.4249 0.0956 0.4965
0.4552 0.7335 0.2597
0.6954 0.1300 0.5917
a(:,:,3,1) =
0.2276 0.1832 0.1372
0.9551 0.6242 0.1889
0.0630 0.2914 0.9566
a(:,:,1,2) =
0.2966 0.0043 0.2240
0.2372 0.0782 0.6953
0.6602 0.3096 0.7002
a(:,:,2,2) =
0.8518 0.5309 0.3834
0.5591 0.8589 0.5954
0.5703 0.4463 0.3050
a(:,:,3,2) =
0.1011 0.6432 0.6211
0.3719 0.7767 0.2791
0.2222 0.4300 0.4780
a(:,:,1,3) =
0.3147 0.1443 0.7440
0.8272 0.0683 0.8357
0.7432 0.5321 0.7207
a(:,:,2,3) =
0.8876 0.8820 0.7249
0.1629 0.4620 0.8836
0.2012 0.1870 0.7980
a(:,:,3,3) =
0.8430 0.5304 0.7167
0.5380 0.8433 0.8627
0.2096 0.2153 0.4713
Now I need a 3D image where all the point should be like the result we get when we use imagesc matlab command.
Upvotes: 0
Views: 285
Reputation: 30579
To display slice #3 (z=3):
zind = 3;
imagesc(squeeze(a(:,:,zind,:)))
Upvotes: 1