ODE 45 couldn't solve the differential equation.
2 views (last 30 days)
I have a differential equation of pump power of eerbium wave guide. The ODE should be solved in matlab. I dont know how to use ODE properly. I have solved only simple ODE in matlab.if you can check it. please.
This is my code.
Nt = [1.2*10^(20), 1.2*10^(20), 1.2*10^(20)];
Tcb = 30*10^(-6);
Tba = 2.3*10^(-3);
for k = 1:3
ode_ = @(z,Pp) (-ap + (((sca*nc)-(sac*na))*Tp*Nt(k)*Pp))';
PSol(z) = ode45(ode_, [0 L], 0);
Pp_sol(k) = PSol;
I need the solution of Pp in three different Nt valus. that is why I have given a for loop. this gives me an error.
% Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
% Error in ode (line 42)
% Pp_sol(k) = PSol;
The z values can't be given as an array. Then it gave me another error,
% Error using odearguments (line 95)
% @(Z,PP)(-AP+(((SCA*NC)-(SAC*NA))*TP*NT(K)*PP))' returns a vector of length 101, but the length of initial conditions
% vector is 1. The vector returned by @(Z,PP)(-AP+(((SCA*NC)-(SAC*NA))*TP*NT(K)*PP))' and the initial conditions vector
% must have the same number of elements.
% Error in ode45 (line 115)
% odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
% Error in ode (line 41)
% PSol(z) = ode45(ode_, [0 L], 0);
I have given it as a random alue to check if the loop is working.