In spite of being real, I get the error: Warning: Imaginary parts of complex X and/or Y arguments ignored.

Hi every one. I have a system of ODE. My solution is real (isreal (A_ODE)=1), but I get this error: Warning: Imaginary parts of complex X and/or Y arguments ignored. Actually I expected the steady- state soIution but I got unstable system. I dont know, is this error massage affected on the answer or not I attached the code and really appreciate any help.
thanks in advance
LaserODE
Warning: Imaginary parts of complex X and/or Y arguments ignored.
Warning: Imaginary parts of complex X and/or Y arguments ignored.
Warning: Imaginary parts of complex X and/or Y arguments ignored.

Answers (1)

dNis = Nis - Nth;
Ais = sqrt((AInj^2 - gammaN/gammaP*dNis)/(1 + g*dNis/gammaP));
dNis is negative.
That makes the numerator for the next line a value minus a negative value, which is positive, so the numerator is okay.
But with dNis being sufficiently negative, the denominator is negative, so overall you are taking square root of a negative value.
phi_Tr = zeros(size(A_Tr));
You do not assign any other value to phi_Tr, so phi_Tr is all zero at the time you semilogy(), which means you are trying to plot the log of 0.

3 Comments

Thank you @Walter Roberson for your help. you are right but I changed semilogy to plot and more important point : I got this error for line 93 ,..,. Ais is initial value. Also, A_ODE, phi_ODE and N_ODE are real. I dont expect something like that. thank you again, I didnot think anyone would read
I know from the steady state solution and physics of the problem that phi must be limited on the set:
. It seems I must impose this constraint on the solution
The problem is solved. these lasers after injection experience non stable situations. I tried to impose constraints on phi, but I couldnt. In steady state solution after calculation we choose between the answers and choose those satisfy the physical conditions. I try to repeat this strategy hear but nothing happens. I changed one key parameter (rInj) and reach the answer.
again very thanks for your help
with the best wishes

Sign in to comment.

Categories

Find more on Programming in Help Center and File Exchange

Products

Release

R2022a

Asked:

on 6 May 2022

Commented:

on 7 May 2022

Community Treasure Hunt

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

Start Hunting!