<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: When is a Numeric Result Not a Number?</title>
	<atom:link href="http://blogs.mathworks.com/loren/2006/07/05/when-is-a-numeric-result-not-a-number/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.mathworks.com/loren/2006/07/05/when-is-a-numeric-result-not-a-number/</link>
	<description>Loren Shure works on design of the MATLAB language at MathWorks. She writes here about once a week on MATLAB programming and related topics.</description>
	<lastBuildDate>Thu, 09 Feb 2012 04:19:21 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Steve L</title>
		<link>http://blogs.mathworks.com/loren/2006/07/05/when-is-a-numeric-result-not-a-number/#comment-31957</link>
		<dc:creator>Steve L</dc:creator>
		<pubDate>Mon, 10 Jan 2011 19:06:22 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=44#comment-31957</guid>
		<description>Any relational operation involving NaN except for NE (not equals, or ~=) returns false.  This is documented on the reference page for the NAN function:

http://www.mathworks.com/help/techdoc/ref/nan.html

So all of these return false:

&lt;pre&gt;
NaN == 0
NaN &gt; 0
NaN &gt;= 0
NaN &lt; 0
NaN &lt;= 0
&lt;/pre&gt;

Only this returns true:

&lt;pre&gt;
NaN ~= 0
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Any relational operation involving NaN except for NE (not equals, or ~=) returns false.  This is documented on the reference page for the NAN function:</p>
<p><a href="http://www.mathworks.com/help/techdoc/ref/nan.html" rel="nofollow">http://www.mathworks.com/help/techdoc/ref/nan.html</a></p>
<p>So all of these return false:</p>
<pre>
NaN == 0
NaN &gt; 0
NaN &gt;= 0
NaN &lt; 0
NaN &lt;= 0
</pre>
<p>Only this returns true:</p>
<pre>
NaN ~= 0
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Maxx</title>
		<link>http://blogs.mathworks.com/loren/2006/07/05/when-is-a-numeric-result-not-a-number/#comment-31949</link>
		<dc:creator>Maxx</dc:creator>
		<pubDate>Sat, 08 Jan 2011 06:50:35 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=44#comment-31949</guid>
		<description>In comparison NaN &gt; 0 gives false. I think you should note about it.

An excellent article! Thank you!</description>
		<content:encoded><![CDATA[<p>In comparison NaN &gt; 0 gives false. I think you should note about it.</p>
<p>An excellent article! Thank you!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2006/07/05/when-is-a-numeric-result-not-a-number/#comment-30979</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Tue, 19 Jan 2010 20:37:50 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=44#comment-30979</guid>
		<description>OysterEngineer,

The class of NaN is double which is a numeric class.  It&#039;s not looking at values, but type.

--Loren</description>
		<content:encoded><![CDATA[<p>OysterEngineer,</p>
<p>The class of NaN is double which is a numeric class.  It&#8217;s not looking at values, but type.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: OysterEngineer</title>
		<link>http://blogs.mathworks.com/loren/2006/07/05/when-is-a-numeric-result-not-a-number/#comment-30978</link>
		<dc:creator>OysterEngineer</dc:creator>
		<pubDate>Tue, 19 Jan 2010 17:19:33 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=44#comment-30978</guid>
		<description>Please explain why a true is returned from:

isnumeric(NaN)</description>
		<content:encoded><![CDATA[<p>Please explain why a true is returned from:</p>
<p>isnumeric(NaN)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2006/07/05/when-is-a-numeric-result-not-a-number/#comment-29525</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Thu, 19 Jun 2008 15:41:32 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=44#comment-29525</guid>
		<description>Gerrit-

Yes, ) * Inf should be 0.  

Think about this.  Anything times 0 is 0.  But inf * anything is infinite.  So with 2 answers possible (at least), how to choose?  The answer is, don&#039;t - return NaN.  MATLAB can&#039;t and doesn&#039;t look at the overall expression you have and calculate limits.  If you need special behavior for 0, code that into the algorithm.

--Loren</description>
		<content:encoded><![CDATA[<p>Gerrit-</p>
<p>Yes, ) * Inf should be 0.  </p>
<p>Think about this.  Anything times 0 is 0.  But inf * anything is infinite.  So with 2 answers possible (at least), how to choose?  The answer is, don&#8217;t &#8211; return NaN.  MATLAB can&#8217;t and doesn&#8217;t look at the overall expression you have and calculate limits.  If you need special behavior for 0, code that into the algorithm.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gerrit</title>
		<link>http://blogs.mathworks.com/loren/2006/07/05/when-is-a-numeric-result-not-a-number/#comment-29524</link>
		<dc:creator>Gerrit</dc:creator>
		<pubDate>Thu, 19 Jun 2008 15:33:12 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=44#comment-29524</guid>
		<description>Should the result of inf * 0 really be NaN? Why? I have a term a .* (1 - (1 + b .* t) .* exp(-(b .* t))), 0&lt;b0 which should yield a for t=inf. Since b * inf is inf it yields nan. Is this on purpose or a bug?</description>
		<content:encoded><![CDATA[<p>Should the result of inf * 0 really be NaN? Why? I have a term a .* (1 &#8211; (1 + b .* t) .* exp(-(b .* t))), 0&lt;b0 which should yield a for t=inf. Since b * inf is inf it yields nan. Is this on purpose or a bug?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve</title>
		<link>http://blogs.mathworks.com/loren/2006/07/05/when-is-a-numeric-result-not-a-number/#comment-5409</link>
		<dc:creator>Steve</dc:creator>
		<pubDate>Fri, 04 Aug 2006 13:48:35 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=44#comment-5409</guid>
		<description>Even though the j doesn&#039;t appear to have a real part, it does -- it has a zero real part.  That zero real part normally doesn&#039;t make a difference in arithmetic operations, but it does when Inf and/or NaN are involved.

j*Inf = (0+1j)*(Inf+0j)
j*Inf = 0*Inf + 0*0j + 1j*Inf + 1j*0j
j*Inf = NaN + 0j + Inf*1j - 0
j*Inf = NaN + Inf*1j.

The case with Inf+j*Inf is as above, except you add Inf to NaN + Inf*1j to obtain NaN + Inf*1j.

Using COMPLEX as you mentioned is the way to obtain the number with 0 real part and Inf imaginary part, or Inf as both real and imaginary part.  Using * does arithmetic; using COMPLEX does not.</description>
		<content:encoded><![CDATA[<p>Even though the j doesn&#8217;t appear to have a real part, it does &#8212; it has a zero real part.  That zero real part normally doesn&#8217;t make a difference in arithmetic operations, but it does when Inf and/or NaN are involved.</p>
<p>j*Inf = (0+1j)*(Inf+0j)<br />
j*Inf = 0*Inf + 0*0j + 1j*Inf + 1j*0j<br />
j*Inf = NaN + 0j + Inf*1j &#8211; 0<br />
j*Inf = NaN + Inf*1j.</p>
<p>The case with Inf+j*Inf is as above, except you add Inf to NaN + Inf*1j to obtain NaN + Inf*1j.</p>
<p>Using COMPLEX as you mentioned is the way to obtain the number with 0 real part and Inf imaginary part, or Inf as both real and imaginary part.  Using * does arithmetic; using COMPLEX does not.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marcelo</title>
		<link>http://blogs.mathworks.com/loren/2006/07/05/when-is-a-numeric-result-not-a-number/#comment-5069</link>
		<dc:creator>Marcelo</dc:creator>
		<pubDate>Thu, 03 Aug 2006 23:38:56 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=44#comment-5069</guid>
		<description>Empty matrices, NaN and Inf are great, but fprintf, fscanf, sprintf and sscanf does not handle then consistently. Another inconsistent results are: j*Inf = NaN + j*Inf; Inf+j*Inf = NaN + j*Inf. My workarrounds for both then are complex(0,Inf) and complex(Inf,Inf).</description>
		<content:encoded><![CDATA[<p>Empty matrices, NaN and Inf are great, but fprintf, fscanf, sprintf and sscanf does not handle then consistently. Another inconsistent results are: j*Inf = NaN + j*Inf; Inf+j*Inf = NaN + j*Inf. My workarrounds for both then are complex(0,Inf) and complex(Inf,Inf).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: per isakson</title>
		<link>http://blogs.mathworks.com/loren/2006/07/05/when-is-a-numeric-result-not-a-number/#comment-3288</link>
		<dc:creator>per isakson</dc:creator>
		<pubDate>Mon, 10 Jul 2006 17:01:09 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=44#comment-3288</guid>
		<description>I work with long time series of experimental data from heating and ventilation systems. I wish

MissingData to indicate that the data aquisition system was not working

NotDef to indicate that the quantity is not defined in the current mode of operation. E.g the inlet air temperature would be NotDef when the air handling unit it not operating.

I should probably include these two in my Time Series Object.

/ per 

Please delete my previous reply. I guess the system swallowed &quot;MissingData&quot; and &quot;NotDef&quot;. / per</description>
		<content:encoded><![CDATA[<p>I work with long time series of experimental data from heating and ventilation systems. I wish</p>
<p>MissingData to indicate that the data aquisition system was not working</p>
<p>NotDef to indicate that the quantity is not defined in the current mode of operation. E.g the inlet air temperature would be NotDef when the air handling unit it not operating.</p>
<p>I should probably include these two in my Time Series Object.</p>
<p>/ per </p>
<p>Please delete my previous reply. I guess the system swallowed &#8220;MissingData&#8221; and &#8220;NotDef&#8221;. / per</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: per isakson</title>
		<link>http://blogs.mathworks.com/loren/2006/07/05/when-is-a-numeric-result-not-a-number/#comment-3286</link>
		<dc:creator>per isakson</dc:creator>
		<pubDate>Mon, 10 Jul 2006 16:50:12 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=44#comment-3286</guid>
		<description>I work with long time series of experimental data from heating and ventilation systems. I wish

 to indicate that the data aquisition system was not working

 to indicate that the quantity is not defined in the current mode of operation. E.g the inlet air temperature is  when the air handling unit it not operating.

I should probably include these two in my Time Series Object.

/ per</description>
		<content:encoded><![CDATA[<p>I work with long time series of experimental data from heating and ventilation systems. I wish</p>
<p> to indicate that the data aquisition system was not working</p>
<p> to indicate that the quantity is not defined in the current mode of operation. E.g the inlet air temperature is  when the air handling unit it not operating.</p>
<p>I should probably include these two in my Time Series Object.</p>
<p>/ per</p>
]]></content:encoded>
	</item>
</channel>
</rss>

