MATLAB: ()-indexing must appear last in an index expression.

darkchannelimage processing

I have this formula. I interested in a DCP. but I want to find atmospheric light with this formula, not function.
for i=1:1:w
for j=1:1:h
A(i,j)=(min(Idark(i,j)>= A(i,j-1))(min(Idark(i,j): A(i,j-1))));
end
end
(w,h image size)
I write like this but it gives the error.( ()-indexing must appear last in an index expression.) can you help me

Best Answer

for i=1:1:w
for j=2:1:h
if (min(Idark(i,j))>= A(i,j-1))
A(i,j)=min(Idark(i,j));
else
A(i,j) = A(i,j-1);
end
end
end