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 CenterFile Exchange에서 Graph and Network Algorithms에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by