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):
Any ideas why the output has both r, s and an "ans" with the same value as r? Doesn't look clean
function [r,s] = absmax(A)
% do some error checking
% Set diagonal to 0
for k = 1:n
A(k,k) = 0;
% 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
Input on better ways of doing what I have done above is greatly appreciated!