solving two differential equation by BVP method (using bvp5c)
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi, I am trying to solve two differential equation by BVP method (using bvp5c).This simulation is a part of a paper and I use a test value for the buondary condition(I mean the value of the BC is not mentioned in the paper and Ijust guess),I want to get Fig.3 of the paper but I dont get result.can anyone help me?
Here is the paper & the M-file I've used.
MATLAB code :
function rt=coupler()
% just A+ & B- two equations
%% Start solving Boundry Value Problem
dbstop if error
L=5e-3;
lambda=linspace(1.5494e-6,1.5506e-6,8)
gp=5.3e-7;
%----------------------------------------------------------------
for i=0:7
i=i+1
lambda(i)
k0=2*pi/lambda(i)
deltaneff=1e-4
kapa=(pi/lambda(i))*deltaneff;
beta1=k0*1.47;
beta2=k0*1.457;
deltabeta1=beta1-pi/gp
deltabeta2=beta2-pi/gp
%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
solinit = bvpinit(linspace(0,L,100),[2.5 0.00000]);
sol = bvp5c(@twoode,@twobc,solinit);
x = linspace(0,L);
y = deval(sol,x);
T(i)=(abs(y(1,end)/y(1,1))^2)
R(i)=(abs(y(2,1)/y(1,1))^2)
end
%-------------------------------------------------------------------------
y(1,1)
y(2,end)
%figure
%plot(x,abs(y(1,:)))
ylabel('y1')
%figure
%plot(x,abs(y(2,:)))
ylabel('y2')
%figure
plot(lambda,T,lambda,R)
ylabel('T , R')
figure
plot(lambda,R)
ylabel('R')
%figure
%plot(lambda,H)
%ylabel('R+T')
%##########################################################################
%Start Functions
function dydx = twoode(x,y)
dydx(1)=1j*kapa*y(2)*exp(1j*(deltabeta1-deltabeta2)*x);
dydx(2)=1j*kapa*y(1)*exp(-1j*(deltabeta1-deltabeta2)*x);
end
function res = twobc(ya,yb)
res = [ ya(1)-2.5 yb(2)];
end
rt=0;
end
0 comentarios
Respuestas (0)
Ver también
Categorías
Más información sobre Purple en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!