<?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: Exceptional Behavior</title>
	<link>http://blogs.mathworks.com/loren/2007/10/26/exceptional-behavior/</link>
	<description>Loren Shure  works on design of the MATLAB language at &#60;a href="http://www.mathworks.com/"&#62;The MathWorks&#60;/a&#62;. She writes here about once a week on MATLAB programming and related topics. &#60;br&#62;&#60;br&#62;&#60;a href="/images/loren-full.jpg"&#62;&#60;img src="/images/loren.jpg"&#62;&#60;/a&#62;</description>
	<pubDate>Mon, 23 Nov 2009 01:17:52 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.1</generator>
		<item>
		<title>By: Chris Rodgers</title>
		<link>http://blogs.mathworks.com/loren/2007/10/26/exceptional-behavior/#comment-29932</link>
		<dc:creator>Chris Rodgers</dc:creator>
		<pubDate>Wed, 17 Dec 2008 13:28:41 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2007/10/26/exceptional-behavior/#comment-29932</guid>
		<description>Hi,

Two thought on exceptions and debugging:

1) Please can we have a way to access the workspace where an exception was thrown, like the dbup / dbdown functions for normal errors. This would make debugging much more powerful. At the moment, a "catch" block prevents one from investigating the error in more detail using the debugger.

2) Please can we have a facility to break when a named variable is assigned to. The Visual Studio C++ debugger has had this option for years and it is very helpful.

Thanks,

Chris.</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Two thought on exceptions and debugging:</p>
<p>1) Please can we have a way to access the workspace where an exception was thrown, like the dbup / dbdown functions for normal errors. This would make debugging much more powerful. At the moment, a &#8220;catch&#8221; block prevents one from investigating the error in more detail using the debugger.</p>
<p>2) Please can we have a facility to break when a named variable is assigned to. The Visual Studio C++ debugger has had this option for years and it is very helpful.</p>
<p>Thanks,</p>
<p>Chris.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2007/10/26/exceptional-behavior/#comment-22925</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Sun, 09 Dec 2007 18:31:21 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2007/10/26/exceptional-behavior/#comment-22925</guid>
		<description>k,

Please contact technical support for more information.  This is not an issue with try-catch or exceptions, the topic of the post.

--Loren</description>
		<content:encoded><![CDATA[<p>k,</p>
<p>Please contact technical support for more information.  This is not an issue with try-catch or exceptions, the topic of the post.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: k</title>
		<link>http://blogs.mathworks.com/loren/2007/10/26/exceptional-behavior/#comment-22917</link>
		<dc:creator>k</dc:creator>
		<pubDate>Sun, 09 Dec 2007 15:41:06 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2007/10/26/exceptional-behavior/#comment-22917</guid>
		<description>Thank you very much. Could I ask some more in detail, please?
For example, repeat 'fscanf' for 50 loops, but Matlab may cause a "timeout" error. I am not sure what I should put in  the "catch" statement. (fclose and fopwn again here?)
--
try,
    for 1+1:1:50,
        measure = fscanf(s);
    end
catch
end
--</description>
		<content:encoded><![CDATA[<p>Thank you very much. Could I ask some more in detail, please?<br />
For example, repeat &#8216;fscanf&#8217; for 50 loops, but Matlab may cause a &#8220;timeout&#8221; error. I am not sure what I should put in  the &#8220;catch&#8221; statement. (fclose and fopwn again here?)<br />
&#8211;<br />
try,<br />
    for 1+1:1:50,<br />
        measure = fscanf(s);<br />
    end<br />
catch<br />
end<br />
&#8211;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2007/10/26/exceptional-behavior/#comment-22916</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Sun, 09 Dec 2007 15:25:41 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2007/10/26/exceptional-behavior/#comment-22916</guid>
		<description>k-

You can use try-catch with pretty much anything.  For a serial port, you just need to be sure to close or delete the port if things don't work out.

--Loren</description>
		<content:encoded><![CDATA[<p>k-</p>
<p>You can use try-catch with pretty much anything.  For a serial port, you just need to be sure to close or delete the port if things don&#8217;t work out.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: k</title>
		<link>http://blogs.mathworks.com/loren/2007/10/26/exceptional-behavior/#comment-22914</link>
		<dc:creator>k</dc:creator>
		<pubDate>Sun, 09 Dec 2007 14:55:40 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2007/10/26/exceptional-behavior/#comment-22914</guid>
		<description>how try/catch can be applied for the functions for serial port? (e.g. fscanf, fprintf, and/or fopen)?</description>
		<content:encoded><![CDATA[<p>how try/catch can be applied for the functions for serial port? (e.g. fscanf, fprintf, and/or fopen)?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2007/10/26/exceptional-behavior/#comment-21158</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Mon, 12 Nov 2007 16:53:20 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2007/10/26/exceptional-behavior/#comment-21158</guid>
		<description>Shivani-

Two issues.  First, you are not using the syntax correctly.  Check the reference page for try/catch to show how to define the MException. 

Second, perhaps you are not using the R2007b release.  If not, you won't have MExceptions available.

---Loren</description>
		<content:encoded><![CDATA[<p>Shivani-</p>
<p>Two issues.  First, you are not using the syntax correctly.  Check the reference page for try/catch to show how to define the MException. </p>
<p>Second, perhaps you are not using the R2007b release.  If not, you won&#8217;t have MExceptions available.</p>
<p>&#8212;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shivani Rao</title>
		<link>http://blogs.mathworks.com/loren/2007/10/26/exceptional-behavior/#comment-21156</link>
		<dc:creator>Shivani Rao</dc:creator>
		<pubDate>Mon, 12 Nov 2007 16:50:55 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2007/10/26/exceptional-behavior/#comment-21156</guid>
		<description>I have been trying to use the try catch block in the new version of matlab R2007a and R2007b 
I used the following syntax
try, 
catch,

end

However i was unable to get this working

try, 
catch, ME1,

end

It kept giving me the error "unknown identifier ME1"

How do we get access to the exception object in this case. None of the support and dicussion forums of matlab give an example of this. 

Some help on this would be greatly appreciated</description>
		<content:encoded><![CDATA[<p>I have been trying to use the try catch block in the new version of matlab R2007a and R2007b<br />
I used the following syntax<br />
try,<br />
catch,</p>
<p>end</p>
<p>However i was unable to get this working</p>
<p>try,<br />
catch, ME1,</p>
<p>end</p>
<p>It kept giving me the error &#8220;unknown identifier ME1&#8243;</p>
<p>How do we get access to the exception object in this case. None of the support and dicussion forums of matlab give an example of this. </p>
<p>Some help on this would be greatly appreciated</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim Davis</title>
		<link>http://blogs.mathworks.com/loren/2007/10/26/exceptional-behavior/#comment-19880</link>
		<dc:creator>Tim Davis</dc:creator>
		<pubDate>Thu, 01 Nov 2007 18:45:16 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2007/10/26/exceptional-behavior/#comment-19880</guid>
		<description>Well, that would be tricky, since sparse matrices didn't exist in MATLAB until 4.0, I think (that's also the version of MATLAB on my coffee mug "MATLAB 4 Picture the Power").

So sure, can I port my codes so they can run on my MATLAB 4 coffee mug?  A MathWorker is a machine that turns coffee into M-files, after all (and C/C++/Java/etc), so I'm sure you're keen to port your codes back there too ... :-)</description>
		<content:encoded><![CDATA[<p>Well, that would be tricky, since sparse matrices didn&#8217;t exist in MATLAB until 4.0, I think (that&#8217;s also the version of MATLAB on my coffee mug &#8220;MATLAB 4 Picture the Power&#8221;).</p>
<p>So sure, can I port my codes so they can run on my MATLAB 4 coffee mug?  A MathWorker is a machine that turns coffee into M-files, after all (and C/C++/Java/etc), so I&#8217;m sure you&#8217;re keen to port your codes back there too &#8230; :-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve Eddins</title>
		<link>http://blogs.mathworks.com/loren/2007/10/26/exceptional-behavior/#comment-19875</link>
		<dc:creator>Steve Eddins</dc:creator>
		<pubDate>Thu, 01 Nov 2007 17:22:24 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2007/10/26/exceptional-behavior/#comment-19875</guid>
		<description>Tim&#8212;Are you really interested in porting code back to run in versions ten years old or more?  Like sparse linear algebra to MATLAB 3.5?  :-)</description>
		<content:encoded><![CDATA[<p>Tim&mdash;Are you really interested in porting code back to run in versions ten years old or more?  Like sparse linear algebra to MATLAB 3.5?  :-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim Davis</title>
		<link>http://blogs.mathworks.com/loren/2007/10/26/exceptional-behavior/#comment-19869</link>
		<dc:creator>Tim Davis</dc:creator>
		<pubDate>Thu, 01 Nov 2007 16:45:40 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2007/10/26/exceptional-behavior/#comment-19869</guid>
		<description>Steve:  Right ... which means determining the version number in, say, MATLAB 5.0 is really important - you can't use try/catch to port code back that far.  And you can't use

if (verLessThan ('MATLAB','5.0'))
...
end

because verLessThan doesn't exist in that version.  I think this would work instead, and should port to, say, MATLAB 2, even (whenever functions were introduced):

if (getversion &#60;= 5)
... MATLAB 5 code here ...
else
... etc.
end

where:

function v = getversion
v = sscanf (version, '%d.%d.%d') ;
v = 10.^(0:-1:-(length(v)-1)) * v ;

returns 6.52 for version 6.5.2, and so on.  It would return 3.2 if "version" returned a string "3.2 (whatever)".  However, the oldest MATLAB I have still running is 6.1.0 (R12.1) so I can't test it on MATLAB 5.x or earlier.

So how old are "version", "sscanf", and "length"  :-) ?</description>
		<content:encoded><![CDATA[<p>Steve:  Right &#8230; which means determining the version number in, say, MATLAB 5.0 is really important - you can&#8217;t use try/catch to port code back that far.  And you can&#8217;t use</p>
<p>if (verLessThan (&#8217;MATLAB&#8217;,'5.0&#8242;))<br />
&#8230;<br />
end</p>
<p>because verLessThan doesn&#8217;t exist in that version.  I think this would work instead, and should port to, say, MATLAB 2, even (whenever functions were introduced):</p>
<p>if (getversion &lt;= 5)<br />
&#8230; MATLAB 5 code here &#8230;<br />
else<br />
&#8230; etc.<br />
end</p>
<p>where:</p>
<p>function v = getversion<br />
v = sscanf (version, &#8216;%d.%d.%d&#8217;) ;<br />
v = 10.^(0:-1:-(length(v)-1)) * v ;</p>
<p>returns 6.52 for version 6.5.2, and so on.  It would return 3.2 if &#8220;version&#8221; returned a string &#8220;3.2 (whatever)&#8221;.  However, the oldest MATLAB I have still running is 6.1.0 (R12.1) so I can&#8217;t test it on MATLAB 5.x or earlier.</p>
<p>So how old are &#8220;version&#8221;, &#8220;sscanf&#8221;, and &#8220;length&#8221;  :-) ?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
