How do I find the area under this curve?

Hi,
I am attempting to learn this program through college. So I am pretty new to this and let me know if I left something out that could help answer my question.
I don't know any other way to ask this but here is what I am putting into my .m file in the text editor.
clear figure(1);clf
mass=105; % kg gravity=-9.81; % m/sec^2 body_area=1; % m^2 weight=mass*gravity;
velocity=0; %initial velocity (m/sec)
TS=0.01; %Time Step t=0:TS:90; % Total time it takes to get to the ground (time vector)
for k=2:length(t)
air_friction_force=-0.65*body_area*velocity(k-1)*abs(velocity(k-1));
total_force=weight+air_friction_force;
acceleration=total_force/mass; % F=ma
change_in_velocity=acceleration;
%integrate velocity
velocity(k)=velocity(k-1)+change_in_velocity*TS;
end
speed=abs(velocity);
figure(1) clf plot(t,speed) xlabel('Time (seconds)') ylabel('Velocity (m/sec)') axis([0,max(t),0,max(speed)+5]);
I need to find the initial position of the object. I am just starting Calculus in College so I don't really know about integration yet. I am just now starting derivatives. Anyway, I think I need to find the area under the curve. Does this give me the initial position?
I don't know the commands to find the area under a curve. Any help would be appreciated :)

Answers (1)

Mischa Kim
Mischa Kim on 23 Mar 2014
Edited: Mischa Kim on 23 Mar 2014
Blake, in your code you compute the velocity as a function of time. If you integrate the resulting velocity over time you'll get position as a function of time.
Typically you use this process to get the final position given the initial position by
x(tf) = x(t0) + v(t)dt
with integration limits t0 and tf. Of course, you can go the other way by
x(t0) = x(tf) - v(t)dt
In short, you need the initial or final position to get the respective other. In your case you can get the integral (= area under the curve) by using
trapz(t,abs(velocity))

Categories

Asked:

on 23 Mar 2014

Edited:

on 23 Mar 2014

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!