Effacer les filtres
Effacer les filtres

how to fix Warning: Imaginary parts of complex X and/or Y arguments ignored

4 vues (au cours des 30 derniers jours)
Faria Siddiqui
Faria Siddiqui le 1 Avr 2021
plot(V,y(:,1),V,y(:,2),V,y(:,3),V,y(:,4),V,y(:,5),V,y(:,6));
This is the line of code the warning pops up for.
my initial conditions are
% yo = [Fa,Fb,Fc,Fd,Fe,Ff,T,x,P]
yo = [9.614 19.435 0 0 35.03391 0 870 0 101.325]
and my V is calculated by
V = ((FA+FB+FC+FD+FE+FF)*R*T)/P
hope someone can help with this!
  1 commentaire
Walter Roberson
Walter Roberson le 1 Avr 2021
My prediction is that P is not a scalar, so the / operator is "matrix right divide", which is similar to
V = ((FA+FB+FC+FD+FE+FF)*R*T) * pinv(P)
Is that the intention?
Anyhow, look at
whos FA FB FC FD FE FF P R T V
and you will see that at least one of them is marked as complex; you will need to trace your code to figure out which one.

Connectez-vous pour commenter.

Réponses (1)

Paul Hoffrichter
Paul Hoffrichter le 2 Avr 2021
Modifié(e) : Paul Hoffrichter le 2 Avr 2021
If you have a negative number raised to a non-integer power, you can sometimes get a complex number. Take a look at:
In this case, there was a very small percentage of complex numbers. Maybe the plot routine knew what was best for the writer by converting automatically the complex numbers to real. The other numbers were real. Matlab is a smart cookie.

Catégories

En savoir plus sur Mathematics dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by