From: William on
Hi, I am trying to write a function to preform calculations and display a curve.
I want these calculations to end once its Y value is equal to zero, and display only what was calculated. Any insight helps!

Here is what i have:


%% Inputs

angle = input('Enter angle of trajectory (degrees)= '); %Angle
V= input('Enter velocity= '); %Velocity
p= input('Enter Position of elevation= '); %Position
G= 9.8; %Gravity
t=0:.01:20; %# of Calculations

%% math/graphics

f= t*V*cosd(angle); %Flight
h1= p+t*V*sind(angle) - 1/2*G*t.^2; %Height
plot(f,h1,'-');pause(0.1); hold on; %Plot
set(gca,'ylim',[0,max(h1)+(max(h1)/4)]) %Graphical restrictions
xlabel('Distance (m)'); ylabel('Height (m)'); %Labels
heightmax = max(h1);


Try angle = 65, velocity = 125, position = 0...notice how far it calculates past 0...how can i restrict this?
 | 
Pages: 1
Prev: rescaling for fmincon
Next: rescaling for fmincon