MATLAB: 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

dynamicsplotplottingprojectile motion

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

Best Answer

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