Why is it only plotting points, not multiple line graphs?

This is the code that I am having a problem with. The UDF I am using will be attached. I do not know how to get multiple line graphs for each of the different velocities that I get. I used the 's' at the plot so that I could clarify to myself if it was actually plotting or not. I was wondering if there was some way to do this with the while loop and not getting rid of it.
clc
clear
close all
V = 100;
hold all
while V<=500
t = [0:.1:30];
h = 10;
A = pi / 6;
hold all
[MaxY] = projectile(t, A, V, h);
plot(MaxY,V,'s')
V = V + 10;
end
title('Launch Velocity vs. Vertical Distance') %Give the Graph a title
xlabel('Maximum Projectile Vertical Distance (m)') %Lable the X-axis
ylabel('Launch Velocity (m/s)')

 채택된 답변

KSSV
KSSV 2018년 10월 11일

0 개 추천

Read about hold on

댓글 수: 4

Jack Gallagher
Jack Gallagher 2018년 10월 11일
편집: Jack Gallagher 2018년 10월 11일
hold on is the same as the hold all function that I am using in my script. I even tried switching the two, but nothing changed.
YOu should run like this:
while V<=500
t = [0:.1:30];
h = 10;
A = pi / 6;
hold all
[x, y, MaxY, X_at_MaxY, T_at_MaxY] = projectile(t, A, V, h);
plot(MaxY,V,'.')
V = V + 10;
end
V = 100;
X = zeros([],1) ;
Y = zeros([],1) ;
count = 0 ;
while V<=500
count = count+1 ;
t = [0:.1:30];
h = 10;
A = pi / 6;
X(count) = V ;
[x, y, MaxY, X_at_MaxY, T_at_MaxY] = projectile(t, A, V, h);
Y(count) = MaxY ;
V = V + 10;
end
plot(Y,X,'.-r')
title('Launch Velocity vs. Vertical Distance') %Give the Graph a title
xlabel('Maximum Projectile Vertical Distance (m)') %Lable the X-axis
ylabel('Launch Velocity (m/s)')
Thank you for helping me with this.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Programming에 대해 자세히 알아보기

질문:

2018년 10월 11일

댓글:

2018년 10월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by