MATLAB: CALCULATION OF MAXIMUM VALUE IN EVERY ROW

maximumpeak finding

suppose there is a matrix of 3×3 size i want to calculate the maximum value in every row.
ex: 3 4 5
6 9 0
1 2 3
the result i should get at the end should be like this
0 0 1
0 1 0
0 0 1
[EDITED, code formatted, Jan]

Best Answer

try this:
suppose the input matrix is A, the output result matrix is B;
max = 0;
k = 0;
l = 0;
for i=1:3
for j=1:5
place(i,j) = 0;
end
end
for i=1:3
for j=1:3
if A(i,j)>=max
max = A(i,j);
place(i,j) = 1
end
end
end
for k=1:3
for l=1:3
if place(k,l) = 1
if place(k,l+1) = 1
B(k,l) = 0;
end
if place[k,l+2) = 1
B(k,l) = 0;
else B(k,l) = 1;
end
else B(k,l) = 0;
end
end
end