error with plotting graph

2 visualizzazioni (ultimi 30 giorni)
garry lyon
garry lyon il 16 Mag 2021
Modificato: Stephan il 16 Mag 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 '.*'.

Risposte (1)

Stephan
Stephan il 16 Mag 2021
Modificato: Stephan il 16 Mag 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);

Categorie

Scopri di più su Graph and Network Algorithms in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by