How can i add a distance to time plot in Matlab
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
0 votes
Share a link to this question
1 Comment
Accepted Answer
2 votes
7 Comments
Yes i believe its s = vt + 0.5*at^2
clear all;
V0=0; % initial speed
m=0.62369; % mass in kg
g=9.82; % gravity acceleration kg/m3
rho=1.225; % Air density
A=0.18/4; % Object area
cw=0.6; % Numerical drag coefficient
k=0.5*cw*rho*A; % Coefficient
N=10; % Time step
V=zeros(1,N); % Speed
V(1)=V0;
deltat=0.2;
for i=1:N-1
V(i+1)=V(i)+deltat*(g-(k/m)*V(i)^2);
t=(0:N-1)*deltat;
d=8- V(i+1)*t + 0.5*(g-(k/m)*V(i)^2)*t.*t % 8 is the starting height
end
vterminal=sqrt(g*m/k); % Terminal velocity
plot(t,d);
xlabel('time in sec');
ylabel('velocity in m/s');
legend ('Euler Method','location','south');
I think this is what you mean right?
But I dont understand why my results vary when i change the Time step
I appreciate your help

My project was to calculate how long it would take a falling abject(Basketball) to reach the ground from a specefic height in this case 8m.
I think I found why I had decreasing derivatives it was because i had a minus after the 8 in :
d=8- V(i+1)*t + 0.5*(g-(k/m)*V(i)^2)*t.*t
I dont know if im thinking right but this is what I have now
clear all;
V0=0; % initial speed
m=0.62369; % mass in kg
g=9.82; % gravity acceleration kg/m3
rho=1.225; % Air density
A=0.18/4; % Object area
cw=0.6; % Numerical drag coefficient
k=0.5*cw*rho*A; % Coefficient
N=8; % Time step
V=zeros(1,N); % Speed
V(1)=V0;
deltat=0.15;
for i=1:N-1
V(i+1)=V(i)+deltat*(g-(k/m)*V(i)^2); % velocity
t=(0:N-1)*deltat; %Time
d=V(i+1)*t + 0.5*(g-(k/m)*V(i)^2)*t.*t % Distance that the Basketball have fallen
end
plot(t,d);
xlabel('time in sec');
ylabel('Distande in m');
legend ('Euler Method','location','south');
Now im getting that it takes the Ball around 0.7s secound to reach the ground from a height of 8m --> x = 0.7 when Y = 8
when we experimented in school the time was around 0.9s
Have I done anything wrong in my calculations?
I really appreciate your help
More Answers (0)
Categories
Find more on Mathematics in Help Center and File Exchange
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)