Solving Coupled ODE's by ODE45
Información
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Mostrar comentarios más antiguos
Dear all,
I have a coupled ODE with two functions. One of them is a gaussian beam. I do want to solve the other one. So far to understand how ode45 works I wrote down such a code which is given below.
gamma = (1e+9)/3
omega = (1e+9)/3
[t,y] = ode45(@(t,y) arbit2(t,y,gamma,omega), [0 20e-9],[0 1]);
plot(t,y(:,1),'-o',t,y(:,2),'-o')
title('Solution of coupled ode with ODE45');
xlabel('Time t');
ylabel('Solution y');
legend('y_1','y_2')
function dydt = arbit2(t,y, gamma, omega)
dydt = [(-gamma-omega)*y(1)+(omega)*y(2); (gamma+omega)*y(1)+(-omega)*y(2)];
end
My question is how can I modify y(1) as a function. For example I want to write a function that gives y(1) as following;
t = 0:1e-15:1e-12;
a=3
y = a*gaussmf(t,[0.5e-13 5e-13]);
I want to solve y(2) according to given y(1) Thanks in advance.
Respuestas (2)
Star Strider
el 19 de Oct. de 2018
If I understand correctly what you want, you can simply modify ‘arbit’ (and calls to it) directly:
arbit2 = @(t,y, gamma, omega,a) [a*gaussmf(t,[0.5e-13 5e-13]); (gamma+omega)*y(1)+(-omega)*y(2)];
gamma = (1e+9)/3
omega = (1e+9)/3
a = 3;
tv = 0:1e-15:1e-12;
[t,y] = ode45(@(t,y) arbit2(t,y,gamma,omega,a), tv,[0 1]);
plot(t,y(:,1),'-o',t,y(:,2),'-o')
title('Solution of coupled ode with ODE45');
xlabel('Time t');
ylabel('Solution y');
legend('y_1','y_2')
It is not an interesting result.
4 comentarios
Ömer Yaman
el 19 de Oct. de 2018
Star Strider
el 19 de Oct. de 2018
Editada: Star Strider
el 19 de Oct. de 2018
Note that ‘y(1)’ is the first row of your ODE function. When I substituted ‘a*gaussmf(t,[0.5e-13 5e-13])’ for it and tweaked ‘arbit2’ to accept ‘a’ as an argument, your function works with ode45.
Unfortunately, it is not clear. I have no idea what you are doing with respect to finding ‘fluorescence time’, since that is not an area of my expertise.
EDIT — (12:48 UCT)
If you want ‘(a*gaussmf(t,[0.5e-13 5e-13])’ as an input to your system, this could work:
arbit2 = @(t,y, gamma, omega,a) [((-gamma-omega)*y(1)+(omega)*y(2)) + (a*gaussmf(t,[0.5e-13 5e-13])); (gamma+omega)*y(1)+(-omega)*y(2)];
It adds the Gaussian as a forcing function to ‘y(1)’.
Ömer Yaman
el 19 de Oct. de 2018
Star Strider
el 19 de Oct. de 2018
I have no idea what
x(t)= gaussian
implies, or what ‘a’ and ‘b’ are.
Try this:
arbit2 = @(t,z,a,b) [(-a-b).*(exp(-(a-z(1)).^2/b)) + b.*z(2); (a+b).*(exp(-(a-z(1)).^2/b))+(-b-z(2))];
Torsten
el 19 de Oct. de 2018
function dydt = arbit2(t,y, gamma, omega)
a=3;
y_fix=a*gaussmf(t,[0.5e-13 5e-13]);
dydt = [(-gamma-omega)*y_fix+(omega)*y(2); (gamma+omega)*y_fix+(-omega)*y(2)];
end
1 comentario
Ömer Yaman
el 19 de Oct. de 2018
La pregunta está cerrada.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!