- #1
mesa
Gold Member
- 695
- 38
Hello all, I am trying to plot a simple trajectory in MATlab. Here is the code I wrote,
v0 = 100;
theta = pi/4;
t=0:0.1:20;
horizontal(t)=t.*v0.*cos(theta)
vertical(t)=t.*v0.*sin(theta)-4.905.*t.^2
%teacher gone missing, again, ARRRGGHHH!
title('Ballistic Trajectory of a Projectile'), xlabel('horizontal distance, m'), ylabel('vertical distance, m')
plot (t,horizontal(t))
I am getting this error,
"Subscript indices must either be real positive integers or logicals."
If I input individual values for 't' it produces the correct results up until the vertical distance reaches it's 'maximum' but do not know why?
v0 = 100;
theta = pi/4;
t=0:0.1:20;
horizontal(t)=t.*v0.*cos(theta)
vertical(t)=t.*v0.*sin(theta)-4.905.*t.^2
%teacher gone missing, again, ARRRGGHHH!
title('Ballistic Trajectory of a Projectile'), xlabel('horizontal distance, m'), ylabel('vertical distance, m')
plot (t,horizontal(t))
I am getting this error,
"Subscript indices must either be real positive integers or logicals."
If I input individual values for 't' it produces the correct results up until the vertical distance reaches it's 'maximum' but do not know why?