How do I fix the plot error for different vector lengths?

This is a homework assignment problem. And I keep getting the error "Error using plot. Vectors must be the same lengths."

 Accepted Answer

You start with t(1) and assign up to t(101+1), so your last t is t(102). Your x_exact is caclulated based on your vector of t, so your x_exact is going to be 102 elements long as well. But your t_exact is linspace(1,10,100) so it is going to be 100 elements long.
Hint: if you were to say linspace(0,1,4) then the points generated would be 0, 1/3, 2/3, 1 -- four points because you asked for 4. If you wanted the points distributed (1-0)/4 = 1/4 apart, then you need linspace(0,1,5)

More Answers (0)

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!