How to solve a system of integro differential equation using numerical method?
Ältere Kommentare anzeigen
integro differential equation
Akzeptierte Antwort
Weitere Antworten (3)
Hewa selman
am 28 Dez. 2021
0 Stimmen
function main
tspan = [0 10];
y0 = [1; 1; 0; 0];
[T,Y] = ode45(@fun,tspan,y0);
plot(T,[Y(:,1),Y(:,2)])
end
function dy = fun(t,y)
dy = zeros(4,1);
dy(1) = t*y(1) + exp(t)*y(3);
dy(2) = t^3*y(1) + exp(-t)*y(4);
dy(3) = exp(-t)*y(2);
dy(4) = exp(t)*sin(y(1));
end
This is the code for your original system of IDEs.
I don't know about the new system you wanted to solve with the code from above.
2 Kommentare
Hewa selman
am 29 Dez. 2021
Seems to work as expected:
function main
y0 = 1 + 1i;
z0 = [1 1];
tspan = [0 2];
[t,y] = ode45(@complexfun, tspan, [y0,z0]);
figure
plot(t,[real(y(:,1)),imag(y(:,1))])
figure
plot(t,[y(:,2),y(:,3)])
end
function f = complexfun(t,y)
f = zeros(3,1);
f(1) = y(1)*t+2*1i;
f(2) = y(2)*t;
f(3) = y(3)*t+2;
end
Hewa selman
am 3 Jan. 2022
Bearbeitet: Hewa selman
am 3 Jan. 2022
0 Stimmen
9 Kommentare
Torsten
am 3 Jan. 2022
In my figure, both real(y(:,1)) and imag(y(:,1)) start at 1.
Hewa selman
am 7 Jan. 2022
You can plot whatever you like - I just decided in the sample code only to plot y1.
But of course you can also include y2 in the plot:
plot (t, [real(y(:,1)),imag(y(:,1)),real(y(:2,)),imag(y(:,2))])
or make separate plots:
figure(1)
plot(t,[real(y(:,1)),imag(y(:,1))])
figure(2)
plot(t,[real(y(:,2)),imag(y(:,2))])
Hewa selman
am 17 Jan. 2022
Bearbeitet: Hewa selman
am 17 Jan. 2022
Hewa selman
am 18 Jan. 2022
And let use any suitable path
What is suitable ? You have to parametrize the chosen path by z(t) (in your case e.g. z(t) = (10+11*i)*t
for 0<=t<=1 if you want to integrate over the line segment connecting 0 and 10+11*i) and rewrite your ODEs in t instead of z.
Then you can proceed as usual by choosing tspan = [0 1].
Hewa selman
am 21 Jan. 2022
Torsten
am 21 Jan. 2022
I hope you took z'(t) into account in the derivative and the integral terms.
Kategorien
Mehr zu Numerical Integration and Differentiation finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!