Return true if the elements of the input vector increase monotonically (i.e. each element is larger than the previous). Return false otherwise. this is my code
function tf = mono_increase(x)% we need to check every number
L=length(x);% we nust use for loop
% then we must use if statement
if L==1 tf=true; % adding a condition for single element
return %we must close the case for faster operation
end for ii = 1:(L-1) if x(ii+1) > x(ii) % we have problems in the -ve numbers
tf= true ; else tf=false ; end end
it doesn't work for negative numbers like : input x= [ -3 -4 1 2 4] the output must be false but I get true I think the wrong is in the indexing
Best Answer