What is NaNi, and how is it different fron NaN?
I am writing a function in Matlab. There should be something wrong. The output of my f开发者_开发问答unction is a vector. When I see every element of my vector I see NaN
(Not a Number) and NaNi
, that really I don´t Know?
Does anybody know what is NaNi?
NaNi
is an imaginary Not-A-Number:
>>NaN*i
ans =
0 + NaNi
Actually NaNi does not exist in Matlab.
when you have a complex number, the displayed values are 'the real part' + 'the complex part' + 'i'. This is shown without a space before the i, try:
(-1)^0.5 %This will give 0.0000 + 1.0000i
This means that if the complex part of the number is NaN, it is printed together with i and appears to be a single word NaNi. For example:
NaN*(1+i) % This will give NaN + NaNi
x = NaN*i % This will give 0 + NaNi
You will find that it is not possible to separately evaluate NaNi or multiply it with 1.
Furthermore the expected outputs are produced when inspecting the result:
real(x) % This will give 0
imag(x) % This will give NaN
精彩评论