x = 0:1:5; % define x array
y = exp(x)+x.^4+2*x.^2-x+3; % define y array
dx = diff(x); % 1 1 1 1 1 dx has one number less than x
dy = diff(y); % -5 -1 -3 -4 -2
slope = dy./dx
z=exp(x)+4*x.^3 +4*x-1
plot(x,slope,'*',x,z)
'Error using plot Vectors must be the same length.'
Been stuck on this for a while, I am not sure what to do. ive seen the other responses to the same error but can not understand the code. It seems its the colon : that might help but i am not sure how to use it.
Any help would be appreciated!