I'm using MATLAB for the first time in two years after taking one introductory class on it. My assignment is to design a function that finds the maximum jump(s), K, between two values in a vector, x, and the position, y, that this jump(s) occurs.
My code currently is this:
function [K,y] = FindMaxJump (x)
a = abs(diff(x)); %Find the jump between successive values
y = find(a == max(a));
K = max(a); %Store the maximum jump in vector K
disp(K) disp(y)
end
Everytime I try to use the function (for example I input FindMaxJump[1 2 5]) I get the error message stated above. Am I using the function wrong or is there an error in my code?
Best Answer