Plot area is empty

5 Ansichten (letzte 30 Tage)
Simba Nduna
Simba Nduna am 10 Okt. 2021
Kommentiert: Star Strider am 10 Okt. 2021
When I plot a function for displacement versus angular position it yeilds a plot. When I plot a function for velocity versus angualar position, it yields a blank plot. This may have to do with my raising the sin/cos terms to powers higher than 1 but I am not sure.
Take a look:
clear;clc;
w=1;
a=0:1:48.1;
y=(95./cosd(a))-95;
yv=(95*w*sind(a))/((cosd(a)).^2);
ya=(95*w^2*(2-((cosd(a)).^2)))/((cosd(a)).^3);
plot(a,y,'r',a,yv,'b',a,ya,'g')
title('magnitude vs angular position')
xlabel('angular postition (θ)')
ylabel('y,c,a')

Akzeptierte Antwort

Star Strider
Star Strider am 10 Okt. 2021
Use element-wise (array) division (./) instead of matrix division (/) and it works. (Matrix division will produce one value, however that will not plot because the plot function only plots lines between points, not the points themselves, unless a marker is also specified.)
This is the most common problem I see on MATLAB Answers.
w=1;
a=0:1:48.1;
y=(95./cosd(a))-95;
yv=(95*w*sind(a))./((cosd(a)).^2);
ya=(95*w^2*(2-((cosd(a)).^2)))./((cosd(a)).^3);
figure
plot(a,y,'r',a,yv,'b',a,ya,'g')
title('magnitude vs angular position')
xlabel('angular postition (θ)')
ylabel('y,c,a')
Consider including a legend to identify the curves.
.
  2 Kommentare
Simba Nduna
Simba Nduna am 10 Okt. 2021
Thanks a lot @Star Strider.
Star Strider
Star Strider am 10 Okt. 2021
As always, my pleasure!
.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by