Azzera filtri
Azzera filtri

loop problems on for cycle

1 visualizzazione (ultimi 30 giorni)
André Sousa
André Sousa il 22 Mag 2014
Risposto: Image Analyst il 22 Mag 2014
Hi there! This is the code I have:
aa=rand(2,2,2); aa(1,1,1)=4; aa(2,1,1)=3; aa(1,2,1)=6; aa(2,2,1)=2; aa(1,1,2)=7; aa(2,1,2)=7; aa(1,2,2)=5; aa(2,2,2)=4; aa; dimention_aa=size(aa);
aareshaped=reshape(aa,[2,4]);
ii=rand(4,1); ii(1,1)=3; ii(2,1)=4; ii(3,1)=5; ii(4,1)=5;
for(j=(ii(1):ii(end)))
ind_reshaped=find(aareshaped==j);
irv=zeros(1,size(ind_reshaped));
irv(1,:)=ind_reshaped
[R1, C1, S1]=ind2sub(dimention_aa,ind_reshaped)
roi_mat=zeros(dimention_aa);
roi_mat(R1,C1,S1)=1
end
I want to store each [R1,C1,S1](a set of positions) on a different vector, but it just overwrites each set. What am I doing wrong?

Risposte (1)

Image Analyst
Image Analyst il 22 Mag 2014
Index them:
[R1(j), C1(j), S1(j)] = ind2sub(dimention_aa,ind_reshaped);

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by