How do I test a vector element by element for imaginary elements
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Asemahle Ndamase
le 8 Avr 2019
Commenté : Asemahle Ndamase
le 9 Avr 2019
Here is the the vector i Have
r =
-1.6659 + 0.0000i
-0.3049 + 1.1564i
-0.3049 - 1.1564i
1.1378 + 0.3231i
1.1378 - 0.3231i
I am trying to check which elements are real numbers by means of a code, then after i'll have to calculate the percentage of those that are imaginary. Pls help
Thank You.
0 commentaires
Réponse acceptée
John D'Errico
le 8 Avr 2019
Modifié(e) : John D'Errico
le 8 Avr 2019
What does the function imag return?
Given that, what would
imag( r ) ~= 0
tell you? see that it returns a true or false value for each element.
Now, how would you compute the fraction of imaginary elements? That seems simple, since you can write things like
sum(imag( r ) ~= 0)
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Read, Write, and Modify Image 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!