Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

Solving Coupled ODE's by ODE45

3 vues (au cours des 30 derniers jours)
Ömer Yaman
Ömer Yaman le 19 Oct 2018
Clôturé : MATLAB Answer Bot le 20 Août 2021
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.

Réponses (2)

Star Strider
Star Strider le 19 Oct 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 commentaires
Ömer Yaman
Ömer Yaman le 19 Oct 2018
Actually I'm trying to solve that.
x'(t)=[(-a-b)*x(t)]+[b*y(t)] y'(t)=[(a+b)*x(t)]+[-b*y(t)]
x(t)= gaussian. I want to solve y(t)
Star Strider
Star Strider le 19 Oct 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
Torsten le 19 Oct 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 commentaire
Ömer Yaman
Ömer Yaman le 19 Oct 2018
if I set a=0, it gives still y(1) result. how?

Cette question est clôturée.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by