<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: How do I test for NaN in my model?</title>
	<link>http://blogs.mathworks.com/seth/2009/02/04/how-do-i-test-for-nan-in-my-model/</link>
	<description>This blog is about Simulink.</description>
	<pubDate>Mon, 23 Nov 2009 00:36:54 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.1</generator>
		<item>
		<title>By: Seth</title>
		<link>http://blogs.mathworks.com/seth/2009/02/04/how-do-i-test-for-nan-in-my-model/#comment-872</link>
		<dc:creator>Seth</dc:creator>
		<pubDate>Thu, 22 Oct 2009 12:16:36 +0000</pubDate>
		<guid>http://blogs.mathworks.com/seth/2009/02/04/how-do-i-test-for-nan-in-my-model/#comment-872</guid>
		<description>@Paul - R2009b has added the ability to detect NaN's to the relational operator.  I posted an update on this topic in a &lt;a href="http://blogs.mathworks.com/seth/2009/09/18/how-do-i-test-for-nan-in-simulink-r2009b-new/" rel="nofollow"&gt;new post here&lt;/a&gt;.</description>
		<content:encoded><![CDATA[<p>@Paul - R2009b has added the ability to detect NaN&#8217;s to the relational operator.  I posted an update on this topic in a <a href="http://blogs.mathworks.com/seth/2009/09/18/how-do-i-test-for-nan-in-simulink-r2009b-new/" rel="nofollow">new post here</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Seth</title>
		<link>http://blogs.mathworks.com/seth/2009/02/04/how-do-i-test-for-nan-in-my-model/#comment-706</link>
		<dc:creator>Seth</dc:creator>
		<pubDate>Wed, 11 Mar 2009 01:52:24 +0000</pubDate>
		<guid>http://blogs.mathworks.com/seth/2009/02/04/how-do-i-test-for-nan-in-my-model/#comment-706</guid>
		<description>@Paul - The approach above is not universal for all kind of NaN testing.  The (x != x) approach can be problematic.  The standard way to do this sort of thing is to use isnan(), isinf(), isfinite(), isnormal(), or fpclassify() and associated enums and constants - available via IEEE math.h include files.  Those functions exist for a reason, and that is consistent detection.  The S-Function builder block provides an easy way to incorporate C functions into your model, and it would only require a couple lines of code.

The issues of detecting NaNs on embedded systems will require specific knowledge of the system, and integration with the operations available on your target hardware.

Thanks for the great discussion!</description>
		<content:encoded><![CDATA[<p>@Paul - The approach above is not universal for all kind of NaN testing.  The (x != x) approach can be problematic.  The standard way to do this sort of thing is to use isnan(), isinf(), isfinite(), isnormal(), or fpclassify() and associated enums and constants - available via IEEE math.h include files.  Those functions exist for a reason, and that is consistent detection.  The S-Function builder block provides an easy way to incorporate C functions into your model, and it would only require a couple lines of code.</p>
<p>The issues of detecting NaNs on embedded systems will require specific knowledge of the system, and integration with the operations available on your target hardware.</p>
<p>Thanks for the great discussion!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul J.</title>
		<link>http://blogs.mathworks.com/seth/2009/02/04/how-do-i-test-for-nan-in-my-model/#comment-693</link>
		<dc:creator>Paul J.</dc:creator>
		<pubDate>Tue, 24 Feb 2009 02:31:23 +0000</pubDate>
		<guid>http://blogs.mathworks.com/seth/2009/02/04/how-do-i-test-for-nan-in-my-model/#comment-693</guid>
		<description>Seth,

Hope you're still checking responses to this topic.  Newsgroup comp.lang.c++.moderated has recently discussed this issue quite a bit.  A lot of people suggested the "if (x != x)" approach, i.e., x != x is true only if x is NaN.  However, a lot of experts came up with some good reasons, not all of which I understood, to explain why this approach could be problematic.  The most obvious reason is that if Simulink generates this code in C, it's possible that a compiler for the embedded platform will optimize it away.  Depends on the compiler and what optimization flags are turned on, IEE7554 compliance, different types of NaNs, etc.  Also, there were lots of other considerations as well.  Does the Simulink approach given above work for different data types (double, int, etc.)? How is isnan implmented in Matlab? Could that implementation be redone in Simulink?  After reading those newsgroup articles, I get the impression that NaN detection is not trivial, particularly for developers using Simulink to develop embedded code for platforms that might have specialized compilers.

Paul</description>
		<content:encoded><![CDATA[<p>Seth,</p>
<p>Hope you&#8217;re still checking responses to this topic.  Newsgroup comp.lang.c++.moderated has recently discussed this issue quite a bit.  A lot of people suggested the &#8220;if (x != x)&#8221; approach, i.e., x != x is true only if x is NaN.  However, a lot of experts came up with some good reasons, not all of which I understood, to explain why this approach could be problematic.  The most obvious reason is that if Simulink generates this code in C, it&#8217;s possible that a compiler for the embedded platform will optimize it away.  Depends on the compiler and what optimization flags are turned on, IEE7554 compliance, different types of NaNs, etc.  Also, there were lots of other considerations as well.  Does the Simulink approach given above work for different data types (double, int, etc.)? How is isnan implmented in Matlab? Could that implementation be redone in Simulink?  After reading those newsgroup articles, I get the impression that NaN detection is not trivial, particularly for developers using Simulink to develop embedded code for platforms that might have specialized compilers.</p>
<p>Paul</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: wei</title>
		<link>http://blogs.mathworks.com/seth/2009/02/04/how-do-i-test-for-nan-in-my-model/#comment-682</link>
		<dc:creator>wei</dc:creator>
		<pubDate>Wed, 11 Feb 2009 16:17:18 +0000</pubDate>
		<guid>http://blogs.mathworks.com/seth/2009/02/04/how-do-i-test-for-nan-in-my-model/#comment-682</guid>
		<description>@Seth - multimedia play list is another example. Richer data structure has to be considered if not just as traditional control development tool, but core software tool as well.</description>
		<content:encoded><![CDATA[<p>@Seth - multimedia play list is another example. Richer data structure has to be considered if not just as traditional control development tool, but core software tool as well.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Seth</title>
		<link>http://blogs.mathworks.com/seth/2009/02/04/how-do-i-test-for-nan-in-my-model/#comment-674</link>
		<dc:creator>Seth</dc:creator>
		<pubDate>Tue, 10 Feb 2009 13:53:47 +0000</pubDate>
		<guid>http://blogs.mathworks.com/seth/2009/02/04/how-do-i-test-for-nan-in-my-model/#comment-674</guid>
		<description>@wei - Thanks for the topic suggestion.  Can you tell me more about how you want to use strings in your model?  I have heard about people wanting to pass error codes and messages around from system to system as strings.  Is that what you are looking to do?

@Andres Feito - Providing a fail-safe back up model makes a lot of sense.  Thanks for sharing the description of your system!</description>
		<content:encoded><![CDATA[<p>@wei - Thanks for the topic suggestion.  Can you tell me more about how you want to use strings in your model?  I have heard about people wanting to pass error codes and messages around from system to system as strings.  Is that what you are looking to do?</p>
<p>@Andres Feito - Providing a fail-safe back up model makes a lot of sense.  Thanks for sharing the description of your system!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andres Feito</title>
		<link>http://blogs.mathworks.com/seth/2009/02/04/how-do-i-test-for-nan-in-my-model/#comment-673</link>
		<dc:creator>Andres Feito</dc:creator>
		<pubDate>Sun, 08 Feb 2009 20:33:15 +0000</pubDate>
		<guid>http://blogs.mathworks.com/seth/2009/02/04/how-do-i-test-for-nan-in-my-model/#comment-673</guid>
		<description>Seth,

We dealt with Nan problems and to protect our model against this kind of problems we built a similar Nan detector. We develop flight control embedded software and we wanted to be protected against it in the remote case it could appear. So when a Nan is detected we made two actions:

We freeze the output of the model so that the Nan will not have the oportunity to leave the model and affect other parts of the system.

We also raise a flag, then the current model is not taken into account and another simpler backup model is executed from this moment on. The Nan problem is not likely to occur in this latter model.</description>
		<content:encoded><![CDATA[<p>Seth,</p>
<p>We dealt with Nan problems and to protect our model against this kind of problems we built a similar Nan detector. We develop flight control embedded software and we wanted to be protected against it in the remote case it could appear. So when a Nan is detected we made two actions:</p>
<p>We freeze the output of the model so that the Nan will not have the oportunity to leave the model and affect other parts of the system.</p>
<p>We also raise a flag, then the current model is not taken into account and another simpler backup model is executed from this moment on. The Nan problem is not likely to occur in this latter model.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: wei</title>
		<link>http://blogs.mathworks.com/seth/2009/02/04/how-do-i-test-for-nan-in-my-model/#comment-671</link>
		<dc:creator>wei</dc:creator>
		<pubDate>Thu, 05 Feb 2009 01:52:29 +0000</pubDate>
		<guid>http://blogs.mathworks.com/seth/2009/02/04/how-do-i-test-for-nan-in-my-model/#comment-671</guid>
		<description>Seth,
Dealing with string in Simulink may be an interesting topic.</description>
		<content:encoded><![CDATA[<p>Seth,<br />
Dealing with string in Simulink may be an interesting topic.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
