How do I plot complex numbers or moduli?
Afficher commentaires plus anciens
Dear Readers,
I have this code. However, there might be a mixture of imaginary and real eigenvalues. I want to plot everything or, if alle eigenvalues are complex, only the moduli. How do I go about this?
eigVals = zeros(2,numel(p));
figure
for k = 1:numel(p)
A = J(c(k), p(k), R(k), c2(k), p2(k));
eigVals(:,k) = eig(A);
hold on;
plot(p(k), eigVals(:,k)', '*');
end
Réponses (1)
KSSV
le 25 Juin 2017
0 votes
You can check whether a value is real or complex using isreal. To get moduli or magnitude of complex number you can use abs. Read about isreal, abs. https://in.mathworks.com/help/matlab/complex-numbers.html
Catégories
En savoir plus sur Mathematics dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!