Here is the code of the functions I'm using.
function max = find_max( matrix )
a = -1;
for i = 1:numel( matrix ),
if ( matrix(i) > a),
a = matrix(i);
end
end
max = a;
end
function maxs = find_maxs( matrix, count )
maxs = [];
while (count > 0),
a = -1;
for i = 1:numel( matrix ),
if ( matrix(i) > a && ~is_present(maxs, matrix(i))),
a = matrix(i);
end
end
maxs = [maxs a];
count = count - 1;
end
end
function present = is_present( vector, element )
for i = 1:numel( vector ),
if ( vector(i) == element),
present = TRUE;
return;
end
end
end
When I try to call:
m = [1 2 3 4];
disp(is_present(m, 1));
Or the function find_maxs, I get this error.
??? Undefined function or method 'is_present' for input arguments of type 'double'.
I'm new to matlab and I don't understand why I'm getting this error. The name of the file is find_max.m, the same name of the first function (which works fine).