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!