MATLAB: Am I getting an error “vectors must be the same length”

graphingplottingvectors

I am trying to call an anonymous function to graph, one graph using 1 resolution, the other using .01 resolution. I keep getting a "vectors must be the same length" error when running.
f=@(x) ((exp(x)).*(sin(x)))./((x.^2)+1);
x = 3:1:7; x1 = 3:.01:7;
plot(x,f(x),x1,f(x))

Best Answer

It's a typo; your last x must be x1
plot(x, f(x), x1, f(x1))
Related Question