# error with plotting graph

조회 수: 1(최근 30일)
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 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);

댓글을 달려면 로그인하십시오.

### Community Treasure Hunt

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

Start Hunting!

Translated by