I'm trying to create a script file that determines the trajctory of a baseball thrown with an initial velocity of 20 m/s, there's no air resistence. I need to plot the trajectories (YX vs Y) for angles between 5 and 85 degress in steps of 10; all on the same plot. For awhile I was able to get a straight line graphed but its suppposed to be a quadratic, now I get errors about improper preallocation, I've seen basic examples but I can't figure out how to get that to work here.
%%%%%code I'm trying to run starts on the next line%%%%
%initial values
xi=0;yi=0;Vi= 20; % meters per second
g=-9.81; %meters per second squared
THy=[5:10:85];THx=[0:1:90];t=zeros(1,3600);for k=1:3600 dt=1; t(k)=(k-1)*dt; THy=[5:10:85]; vyi=Vi*sind(THy);%initail vel. in y
vyx=Vi*cosd(THy);%initial vel. in x
Y(:,t)=yi+vyi*t+.5*g*(t^2);%height of the ball
YX(:,t)=xi+vyx*t;%horizonatal distance traveled, no air resitance
end plot(YX,Y)
Best Answer