Any ideas on locating complex numbers in a matrix and changing their value to zero?
Mostra commenti meno recenti
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! :)
Risposta accettata
Più risposte (2)
Jos (10584)
il 30 Nov 2013
Take a look at isreal.
Z(~isreal(Z)) = 0 ;
Categorie
Scopri di più su Convert Image Type in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!