Hello all, I am trying to plot a simple trajectory in MATlab. Here is the code I wrote,(adsbygoogle = window.adsbygoogle || []).push({});

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?

**Physics Forums - The Fusion of Science and Community**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Having difficult time trying to plot a simple trajecory

Tags:

Loading...

Similar Threads - Having difficult trying | Date |
---|---|

Matlab Does MatLab have this kind of function? | Jan 15, 2017 |

Matlab -- how can i use a FOR loop if I have 2 variables changing | Oct 12, 2016 |

I have a problem with mathematica | Jan 17, 2014 |

I have a problem with mathematica | Aug 30, 2013 |

Plotting and Integrating difficult functions/Maple or mathematica | Aug 9, 2011 |

**Physics Forums - The Fusion of Science and Community**