필터 지우기
필터 지우기

What am I doing wrong here I keep getting a plot with either to many things on it or not enough all I want is a plot with two y axis and an x axis

조회 수: 1 (최근 30일)
theta = 46.97;
theta2= 55;
v1= 13.5;
v2= 16.05;
x= (0:0.1:2.3);
x2= (0:0.1:5.14);
y= x*tan(theta)-(g/(2*v1.^2*cos(theta).^2))*x.^2;
y1= x2*tan(theta2)-(g/(2*v2.^2*cos(theta2).^2))*x2.^2;
yyaxis right
plot(x,y)
plot(x2,y1)
hold on

채택된 답변

Alan Stevens
Alan Stevens 2021년 1월 13일
Like this
g = 9.81;
theta = 46.97;
theta2= 55;
v1= 13.5;
v2= 16.05;
x= (0:0.1:2.3);
x2= (0:0.1:5.14);
y= x*tan(theta)-(g/(2*v1.^2*cos(theta).^2))*x.^2;
y1= x2*tan(theta2)-(g/(2*v2.^2*cos(theta2).^2))*x2.^2;
plotyy(x,y,x2,y1),grid
  댓글 수: 2
Alan Stevens
Alan Stevens 2021년 1월 13일
It worked for me! However, an alternative is
g = 32.2;
theta = 46.97;
theta2= 55;
v1= 13.5;
v2= 16.05;
x= (0:0.1:2.3);
x2= (0:0.1:5.14);
y= x*tan(theta)-(g/(2*v1.^2*cos(theta).^2))*x.^2;
y1= x2*tan(theta2)-(g/(2*v2.^2*cos(theta2).^2))*x2.^2;
plot(x,y),grid
ylabel('y')
yyaxis right
plot(x2,y1)
ylabel('y1')
xlabel('x')
This results in

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by