error with plotting graph

2 ビュー (過去 30 日間)
garry lyon
garry lyon 2021 年 5 月 16 日
編集済み: Stephan 2021 年 5 月 16 日
a = 13;
c = 17;
k = 2*pi/3;
theta = 0:0.0001:2*pi;
d2b = -(a*(cos(theta)*(c^2 - a^2*sin(theta).^2).^(3/2) + a^3*sin(theta).^4 + a*c^2*cos(theta).^2 - a*c^2*sin(theta).^2))./(c^2 - a^2*sin(theta).^2).^(3/2);
figure(3)
plot (theta, d2b);
this function isnt letting me plot a graph and it comes up with this message below
Error using *
Incorrect dimensions for matrix multiplication. Check that the number of columns in the first matrix matches the number of rows in the second matrix. To perform
elementwise multiplication, use '.*'.

回答 (1 件)

Stephan
Stephan 2021 年 5 月 16 日
編集済み: Stephan 2021 年 5 月 16 日
Since theta is a vector you need to perform elementwise multiplication:
a = 13;
c = 17;
k = 2*pi/3;
theta = 0:0.0001:2*pi;
d2b = -(a*(cos(theta).*(c^2 - a^2*sin(theta).^2).^(3/2) + a^3.*sin(theta).^4 + a*c^2.*cos(theta).^2 - a*c^2.*sin(theta).^2))./(c^2 - a^2*sin(theta).^2).^(3/2);
figure(3)
plot (theta, d2b);

カテゴリ

Help Center および File ExchangeGraph and Network Algorithms についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by