finding the distance traveled before speed is reduced to a certain velocity
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
so i am given mass of an airplane, v1 and v2, F= -5*v^2 -570000 and the equation mv(dv/dx)= -5*v^2 - 570000
and i have to find how far the airplane travels before its speed is reduced to v2 using the trapezoid rule
So far i have
function Q = trapz( a,b,n )
x= linspace (a,b,n+1);
h = (b-a)/n;
Q = 0;
for i= 1:n
Q = Q + .5*(func(x(i))+func(x(i+1)))*h;
end
end
and i have
function value = Force(v)
value = -5*v^2-570000;
I don't know if i am on the right path or what to do from here. Please help and thank you
3 commentaires
darova
le 28 Oct 2019
if F = -5v^2 - 570000 then m(dv/dt) = F
Looks like diff equation
You can use ode45 to solve it
Réponse acceptée
Asvin Kumar
le 1 Nov 2019
The original equation from your question is .
Rearranging the terms would give .
We would need to integrate the equation above as follows to obtain the distance travelled:
Try using the following code to obtain that. This is just a modified version of the code you had provided which uses the trapezoidal method:
trapz(93,40,1e3,0)
% a is initial point
% b is final point
% n-1 is the number of points in between a and b
% ic is the initial condition
function Q = trapz( a,b,n,ic )
x = linspace (a,b,n+1);
h = (b-a)/n;
Q = ic;
for i= 1:n
Q = Q + .5*(func(x(i))+func(x(i+1)))*h;
end
% % optimized code below
% tmp = func(x);
% Q = ic + h * ( sum(tmp)-0.5*(func(a)+func(b)) );
end
function val = func(v)
m = 97e3;
val = (m*v)./(-5*v.^2-57e4);
end
As darova had mentioned in their comment this can also be solved using ode45. Comparing with its documentation, the variable of differentation (t) in this case is 'v' while the variable being differentiated (y) is 'x'.
The code for that is:
[v,x] = ode45(@(t,y) 97e3*t/(-5*t.^2-57e4) ,[93 40],0);
plot(v,x)
Have a look at an example from the documentation solving a similar problem: https://www.mathworks.com/help/matlab/ref/ode45.html#bu3ugj4
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Numerical Integration and Differential Equations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!