Any ideas on locating complex numbers in a matrix and changing their value to zero?
Mostrar comentarios más antiguos
Hello dear Mathworks world. I am having a little problem using the surf function in order to plot an energy surface with respect to two independent compositions (in a ternary system).
The problem seems to lie with the way I generate the solution, called Z. For some combinations of compositions, Z is is complex (which makes sense because they would be impossible in real life). However, the z matrix is quite large and changing these by hand would be intense (I cant even find them to be honest).
I was thinking of using something like: find(GS==nan) = 0; but this did not seem to work. Is there any way to set an elegant constraint on GS to not permit complex numbers in the solution space? I am still pretty new to the world of matlab so any advice is much appreciated.
Thank you! :)
Respuesta aceptada
Más respuestas (2)
Jos (10584)
el 30 de Nov. de 2013
Take a look at isreal.
Z(~isreal(Z)) = 0 ;
Categorías
Más información sobre Polar Plots en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!