I'm learning Matlab for the first time and I was able to get the first graph working but i'm having trouble getting the graph of the derivative to work. I keep getting an error message that "vectors must be the same lengths" and that i have an error in line 9.
x = (0:0.02:5);y= exp(-2*x).*sin(2*x);subplot(1,2,1)plot(x,y),xlabel('x'),ylabel('y'), axis([0 5 -1 1])hold ondiff(y) %differentiation
f = diff(y);plot(x,f,'r'),xlabel('x'),ylabel('f'), axis([0 5 -1 1]) <-------line 9
Best Answer