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."

 采纳的回答

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)

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Dates and Time 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by