my code is entering infinite loop when i am trying to solve differential equation using ode45 command , can some one help me fix this
Mostra commenti meno recenti
function dE_dz =asim(z,E1,~,~)
c=3*1e8;
L=800*10^-9
pi=3.1415926535;
Dk=20.94;
w1=(2*pi*c)/L;
%w1=fs*[-N/2:N/2-1];
deff=2.0657e-12;
Lc=2*pi/Dk;
Lnl=50*Lc;
n2=5*10^-16;
I0=10^-9;
dE_dz = (-1i*conj(E1).*E1.^2.*w1*deff)/(c*n2*Dk)+ 1i*2*pi*(n2*I0)*(Lnl/L)*((abs(E1)).^2).*E1 +...
+ 1i*4*pi*(n2*I0)*(Lnl/L).*((-w1*deff.*E1.^2*exp(-1i*Dk*z))/(c*n2*Dk)).^2.*E1;
end
clc; clear all; close all; clf;
Pi=1.98; %input('Enter the value of input power in mW ')
t=120*10^-15 %input('Enter the value of input pulse width in seconds ')
tau=-300*10^-15:0.1*10^-15:300*10^-15; %input('Enter time period with upper(U), lower(L) and interval between upper and lower interval(I) in this format L:I:U')
dt=1e-15/t
fs=1/dt;
pi=3.1415926535;
Ao=sqrt(Pi) % amplitude of an input gaussian pulse
h=2000 % small step as defined by split step algorithm
%for ii=0.1:0.1:(s/10) %1*10^-7:1*10^-7:s %different fiber lengths
E1=Ao*exp(-(tau/t).^2); % generation of an gaussian input pulse
figure(1)
plot(tau,abs(E1)); % graph of input pulse
title('Input Pulse'); xlabel('Time in ps'); ylabel('Amplitude');
grid on;
hold on;
[z,E1]=ode45(@asim,[0 1.0],0.6325)
%q = ode45(@(z,E1)asim(z,E1,~,~),[0 1],E1_0);
% time=
% % % tau1=L*(-300*10^-15:300*10^-15);
plot(z,E1);
3 Commenti
madhan ravi
il 10 Ott 2018
upload asim function and format your code correctly to get an answer
asim asrar
il 10 Ott 2018
Walter Roberson
il 10 Ott 2018
Why do you think you have an infinite loop? Perhaps your equations are just stiff or oscillate enough that they have to be integrated with a small step size.
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Programming in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!