MATLAB: Indexing in loop, cell

cell loop for

I have cell Z
in cell Z{1}=
Columns 1 through 6
[1x3 double] [1x3 double] [1x3 double] [1x3 double] [1x3 double] [1x3 double]
Column 7
[1x3 double]
Z{2}= [1x3 double] [1x3 double]
MAXP= (max count object in cell Z{1} have 7 object
Z{2} have 2 oject)
MAXP=1
my code:
for i=1:size(Z,2)
if length(Z{i})>MAXP
for j=1:length(Z{i})
a=([Z{i}{j};M(i,:)]);
odch(j,:)=std(a);
end
odch
maxval=max(max(odch));
[i_max,j_max]=find(odch==maxval);
for j=1:length(Z{i})
for c=1:length(Z{i}{j})
if j==i_max && c==j_max
value=Z{i}{j}(c)
end
end
end
number=value/2
W={};
for j=1:length(Z{i})
if all((Z{i}{j})>number)
W{i}{j}=Z{i}{j};
else
W{i+1}{j}=Z{i}{j};
end
end
end
end
W
When i have size(Z,2)=2, I dont know how I then index W to me it do not overwrite.
I need overwrite the variable odch.

Best Answer

Before the first
for j=1:length(Z{i})
add
odch = [];