ODE coupled with classic equation
1 view (last 30 days)
Show older comments
Hi everybody.
After some research can't found a solution..
I have 2 variable wich depend on time : E and W(E)
then I have an differential equation of rho inked to W so linked to E so linked to t.
Can I use E et W as vector inside the ODE declaration?
clc
clear all
close all
u=2.405;
c=3e8;
T0=100e-15;
lambda0=515e-9;
w0=2.*pi.*c./lambda0;
Ej=100e-6;
Pp=Ej./T0;
r=18e-6;
th=250e-9;
s=0.085;
dt=T0./1000;
t=-T0*5:dt:T0*5;
Fs=1./dt;
nn=length(t),
freq = Fs*linspace(0,(nn/2),(nn/2)+2)/nn+c/lambda0;
freq=fliplr(freq(1:end-1));
l=c./freq;
ll=-fliplr(l);
lll=ll-ll(1)+l(end);
lll = (circshift(lll',-1))';
lambda=[l lll];
lambda=lambda(1:end-1);
w=2.*pi.*c./lambda;
E=Pp.*exp(-(t./T0).^2).*cos(w0.*t);
% plot(t,E)
a=r.*( 1+ s.*(2*pi.*c).^2./ (w.*w.*r.*th) ).^(-1);
% plot(lambda,a)
a=9.9992e28;
b=3.5482e11;
rho0=2.7e26;
W=a./(abs(E)).*exp(-b./(abs(E)));
syms rho(t) EE(t) WW(t)% Y ;
ode1= EE== Pp.*exp(-(t./T0).^2).*cos(w0.*t);
ode2 = WW==a./(abs(EE)).*exp(-b./(abs(EE)))
ode3 = diff(rho,t) == W(t) .*(rho0 - rho);
ode=[ode1 ode2] ode3
rhoSol=solve(ode)
%%%or
yms rho(t) ;
ode = diff(rho,t) == W(t) .*(rho0-rho);
rhoSol=solve(ode)
If you have an idea to solve this?
Regards
MM
2 Comments
Accepted Answer
darova
on 23 Oct 2019
Try this
E = @(t) E0*exp(-t^2/tau^2)*cos(w0*t);
w = @(t) a/E(t)*exp(-b/E(t));
rho = @(t,rho) w(t)*(rho-rho0);
[t,r] = ode45(rho,[0 0.1],1);
plot(t,r)
7 Comments
darova
on 23 Oct 2019
- It's not r wich is drho/dt (the solution if their is)?
Yes. BUt if rho is inf or NaN drho/dt cannot be found. You asked why all r are NaN - this is the answer, because of rho
More Answers (1)
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!