Hi!
I know a simple semicolon at the end of any command avoids output of the result of that command, but sometimes it shows up in any case. Any ideas?
Example, my function below (it returns the positions of the maximum entry in a matrix, that is *not* on the diagonal):
Code:
function [r,s] = absmax(A)
% do some error checking
% Set diagonal to 0
for k = 1:n
A(k,k) = 0;
end
% Get the largest element from each column, store elements in m and indices in i
[m, i] = max(abs(A));
% Get the largest element from m, store it in t and its position in s
[t, s] = max(m);
% Pos r is the value of elementh s in i
r = i(s);
% Return r, s
r
s
end
Any ideas why the output has both r, s and an "ans" with the same value as r? Doesn't look clean
Input on better ways of doing what I have done above is greatly appreciated!