Storing matrices from a loop in an array
古いコメントを表示
My program takes a 3D matrix and creates as many 2D matrices as the size of the third dimension. This matrices are later represented as images. The problem is my code isn't really storing this matrices but overwriting them everytime. I need to store them in another array. I also need to store only those matrices that are not made up of only zero values. I have successfully obtained the number of only-zero matrices but I haven't succeeded in storing them. What is the best way to do this?
n=1;
for s=1:d3
thisimage=MA(:,:,s);
%counts how many matrices have only zero values
if sum(thisimage)==0
n=n+1;
end
% create a new matrix, size, minus the zero only matrices
%store non zero matrices in this vector
t=cell(d3-n);
if sum(thisimage)~=0
t(s)=thisimage;
end
subplot(12,17,s),subimage(thisimage);figure(gcf)
axis off
colormap(gray);
%%Draw only every five images
s=s+5;
end
Thank you for your help
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Image Arithmetic についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!