Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
Solving Coupled ODE's by ODE45
조회 수: 1 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
답변 (2개)
Star Strider
2018년 10월 19일
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
Star Strider
2018년 10월 19일
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
2018년 10월 19일
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
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!