flag an error message when a scalar is complex
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
msh
am 31 Mai 2015
Kommentiert: Nobel Mondal
am 31 Mai 2015
Hi,
I would like to include in my algorithm an error message where it will tell me that a scalar is complex. So for example I would like to implement in Matlab the following idea
if scalar == complex number
show error message
end
How I can implement this Matlab ?
Thanks
0 Kommentare
Akzeptierte Antwort
Nobel Mondal
am 31 Mai 2015
if ~isreal(num)
error('This is a complex number.')
end
2 Kommentare
Nobel Mondal
am 31 Mai 2015
Yes, num is the scalar which you want to check for.
For matrix:
>> A = [ 1 2 3; 4 5+6i 7];
>> isreal(A)
ans =
0
>> isreal(A(1,1))
ans =
1
>> isreal(A(2,2))
ans =
0
Hope this clear things up for you.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!