error with plotting graph

1 visualización (últimos 30 días)
garry lyon
garry lyon el 16 de Mayo de 2021
Editada: Stephan el 16 de Mayo de 2021
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 '.*'.

Respuestas (1)

Stephan
Stephan el 16 de Mayo de 2021
Editada: Stephan el 16 de Mayo de 2021
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);

Categorías

Más información sobre Graph and Network Algorithms en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by