I have written the following 'matlab' code that is supposed to return the maximum value in an array:
function m = maxi(a)
maximum = a(1,1);
[m,n]=size(a);
for i=1:m
    for j=1:n
        if a(i,j)>=maximum
            maximum = a(i,j)
        else
            maximum = maximum;
        end
    end
end
m = maximum;
end
The case here is that the returned result seems to be the maximum number in each iteration. How can I return only one value, which is the maximum value?
Thanks.
 
    