Numerically solving first-order integro-differential equation
1 view (last 30 days)
Show older comments
Can anyone help me solve the following equation numerically:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/412773/image.png)
where a = 8, b = 5.3e+04, c = 22, d = 2, e = 100, and v(0) = eps.
I wrote the following code for t in the range 0 to 1, but there is an error with the integral term.
clear all
clc
syms v_p(t) t
eqn(1) = diff(v_p,1) == -8 - CD(v_p)*abs(v_p)*v_p - 5.3e4*Int(v_p,t);
pretty(eqn)
[V] = odeToVectorField(eqn);
fun = matlabFunction(V,'Vars', {'t','Y'});
tInterval = [0 1];
vInit = [eps];
vSol = ode45(fun,tInterval,vInit);
tValues = linspace(tInterval(1),tInterval(2),100);
vValues(1:length(tValues)) = deval(vSol,tValues,1);
plot(tValues,-vValues)
function getCD = CD(v_p)
getCD = 22 + 2/abs(v_p) + 100/(1+sqrt(abs(v_p)));
end
function getInt = Int(v_p,t)
T = linspace(0,t);
Int_diff = zeros(1, length(T));
for i = 1:length(T)
[~, y] = ode45(@(s,y) diff(v_p,s)/sqrt(T(i)-s), [0 T(i)+eps], eps);
Int_diff(i) = y(end);
end
getInt = Int_diff(end)
end
0 Comments
Answers (0)
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!