Dear Experts,
I have some loop problem in matlab, I can't find where is the exact problem in my loop , Could please help me in that 🙂
A = [ 0 1 2 3 4 25 6 7 8 9 ; 9 5 1 20 3 6 4 7 8 5]'
for i=1:size(A,1) for n=1:size(A,2) if A(i,n) == max(A(:,n)) A(i,n)=1 else A(i,n)=0 end end end
the Correct result I expect from the program like this :
0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0
But I getting the error result like
0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 1 1 1
Many thanks
Good weekend
With Regards
Sayanta
Best Answer