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 Center および File Exchange2-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