Error in the execution of the solution of first ODEs nonlinear equations with imaginary coefficients

i need the the value of b2 from the following differential equation
(db1/dz)-(i*beta1*b1) = (C*b2)
(db2/dz)- (i*beta2*b2) = -(C*b1)
with the boundary conditions:
b1(z=0) = 1, b2(z=0) = 0
where the value of beta1 = 7.2e+06, beta2 = 7.1e+06, and C = 0. so please send the correct solution. i am sending my code with this mail in which
The error which we are getting after running the program it is attached with in JPEG form
clc;
clear all;
close all;
format long;
n1 = 1.453755; % Referactive Index of the Core Region
n2 = 1.450588; % Referactive Index of the First Cladding Region
% Find the difference between n1 & n2
n = n1-n2;
disp('n = ');
disp(n);
n3 = 1; % Referactive Index of the First Cladding Region
lambda =1.3*10^-6; % Wavelenth of the Proapagating Light in Micrometer
% Find the value of propagation constant k
k = 2*pi/lambda;
disp('k = ');
disp(k);
rho25 = 4.53038170273*10^-6; % Radius of the core region in micrometer
rhocl25 = 57.535847624671*10^-6; % Radius of the cladding in micrometer
S25 = (rhocl25/rho25)
nf25_01 = 1.45200634;
nf25_02 = 1.4505416;
V25 = rho25*k*sqrt(n1^2-n2^2)
bt25_01 = k*(nf25_01)
bt25_02 = k*(nf25_02)
C25=0;
%%calculation of the b1 at z = z1 when boundary conditions are b1(z=0)=1, b2(z=0)=0.
ode1 = 'Db1 = (i*(bt25_01)*b1)-(C25*b2)';
ode2 = 'Db2 = (i*(bt25_02)*b2)-(C25*b1)';
initials = 'b1(0)=1, b2(0)=0';
b2 = dsolve('ode1','ode2', 'initials', 'z')
% br2 = roots([1, (i*bt25_02)])
% bb2 = abs(br2)

Answers (2)

syms beta1 beta2 C b1(z) b2(z)
sol=dsolve(diff(b1)-1I*beta1*b1==C*b2, diff(b2)-1I*beta2*b2==C*b1, b1(0)==1, b2(0)==0);
or
Best wishes
Torsten.

5 Comments

no its not working dear if you have matlab then try yours self and if you find some sufficient correction please give me a ping
What's the error message you get when you execute the above two lines ?
I don't have MATLAB at hand.
(By the way: the solution for C=0 is
b1(z)=exp(1I*beta1*z), b2(z)=0
)
Best wishes
Torsten.
Error using assignin Invalid variable name "b1(z)" in ASSIGNIN.
Error in syms (line 56) assignin('caller',varargin{i},sym(varargin{i}));
Error in CMT_1 (line 34) syms beta1 beta2 C b1(z) b2(z)
>> CMT_1 Error: File: CMT_1.m Line: 28 Column: 22 Unexpected MATLAB expression.
I guess you entered
syms beta1 beta2 C b1(z) b2(z)
sol=dsolve(diff(b1)-1I*beta1*b1==C*b2, diff(b2)-1I*beta2*b2==C*b1, b1(0)==1, b2(0)==0)
sol.b1
sol.b2
?
Best wishes
Torsten.
no dear it also won't work if you can find matlab for some time then you can try ....i have somewhat modified the code but its answers are coming null matrix values of b1 and b2
i run the following
syms beta1 beta2 C b1 b2
sol=dsolve('Db1-(i*(beta1)*b1)=C25*b2', 'Db2-(i*(beta2)*b2)=-C25*b1', 'b1(0)=1, b2(0)=0', 'z')

Sign in to comment.

ode1 = subs(sym('diff(b1(z),z) = (i*(bt25_01)*b1(z))-(C25*b2(z))'));
ode2 = subs(sym('diff(b2(z),z) = (i*(bt25_02)*b2(z))-(C25*b1(z))'));
initials = [sym('b1(0)=1'), sym('b2(0)=0')];
b2 = dsolve(ode1, ode2, initials, 'z')

Asked:

on 22 Jul 2015

Answered:

on 25 Jul 2015

Community Treasure Hunt

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

Start Hunting!