How do I test a vector element by element for imaginary elements
6 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
John D'Errico
2019-4-8
编辑:John D'Errico
2019-4-8
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)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Read, Write, and Modify Image 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!