フィルターのクリア

Plotting the parametric curve and its second derivative

3 ビュー (過去 30 日間)
Szabolcs Simon-Guth
Szabolcs Simon-Guth 2021 年 11 月 9 日
コメント済み: Star Strider 2021 年 11 月 9 日
Hi everyone!
I would like to plot a parametric curve of a two-variable fuction (parameters x and y, in the code below), along with its second derivative (ax, ay in the code below).
I have written the code below, however when I run the code I get an error stating: Arrays have incompetible sizes for this operation. This error applys to the line where I have defined the second derivative (i.e.: ax, ay). I do not understand what the problem is. Could anyone give me a hint? Thank you very much for all help in advance!
The code:
t = linspace(0, 3, 1000);
% Plotting the function
k = exp(-t);
x = k.*(cos(10*t)+0.3*sin(10*t));
y = k.*(sin(10*t));
plot(x,y, '-k', 'LineWidth', 1.5)
axis equal
hold on
% Picking 100 points in the function
i = 1:10:1000;
ts = t(i);
xs = x(i);
ys = y(i);
% Calculating and plotting the second derivative at the given 100 points
ax = k.*((-9.7.*sin(10.*ts)-(105.*cos(10.*ts))));
ay = k.*((99.*sin(10.*ts)+(20.*cos(10.*ts))));
quiver(xs,ys,ax,ay, 'LineWidth',2,'Color','r')
hold off

採用された回答

Star Strider
Star Strider 2021 年 11 月 9 日
Is that is necessary to subscript ‘k’ so that it is the same size as the other elements in the calculation —
t = linspace(0, 3, 1000);
% Plotting the function
k = exp(-t);
x = k.*(cos(10*t)+0.3*sin(10*t));
y = k.*(sin(10*t));
plot(x,y, '-k', 'LineWidth', 1.5)
axis equal
hold on
% Picking 100 points in the function
i = 1:10:1000;
ts = t(i);
xs = x(i);
ys = y(i);
% Calculating and plotting the second derivative at the given 100 points
ax = k(i).*((-9.7.*sin(10.*ts)-(105.*cos(10.*ts))));
ay = k(i).*((99.*sin(10.*ts)+(20.*cos(10.*ts))));
quiver(xs,ys,ax,ay, 'LineWidth',2,'Color','r')
hold off
.
  2 件のコメント
Szabolcs Simon-Guth
Szabolcs Simon-Guth 2021 年 11 月 9 日
Thank you! I have not noticed that little error. Much appriciated! :)
Star Strider
Star Strider 2021 年 11 月 9 日
As always, my pleasure!
.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by