How do I plot this vector curve?
3 ビュー (過去 30 日間)
古いコメントを表示
Very new to matlab, still learning.
How do i plot the curve parametrized by P(t) = (1 - cos t)i + (1 + 2t + t^2)j for 0<=t<=1?
I have tried
x=linspace(-1,1)
i = 1 - cos(t)
j= 1 + 2*t + t.^2
plot(x,i,x,j)
but it says "Vectors must be the same length." Any idea what I'm doing wrong here?
0 件のコメント
採用された回答
Cam Salzberger
2017 年 10 月 19 日
編集済み: Cam Salzberger
2017 年 10 月 19 日
Hello Jason,
"(1-cos(t))i" means that this point will be at the x-coordinate "1-cos(t)" for time t. Similarly for "j" -> y-coordinate. So you're on the right track, but the trick is to know that MATLAB doesn't care what time it is while plotting. It only wants to know the x and y coordinates.
t = linspace(-1, 1, 10);
x = 1 - cos(t);
y = 1 + 2*t + t.^2;
plot(x, y)
The error was likely because you were defining "x" instead of "t" in the first line, but you had an existing "t" value left over from before. Be careful about that when writing scripts.
Also, I'd recommend against using "i" or "j" as variable names in MATLAB, since they have a built-in meaning as the imaginary unit.
-Cam
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Fit Postprocessing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!