<?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: Convenient nargout Behavior</title>
	<link>http://blogs.mathworks.com/loren/2009/04/14/convenient-nargout-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>Sun, 22 Nov 2009 23:46:46 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.1</generator>
		<item>
		<title>By: OysterEngineer</title>
		<link>http://blogs.mathworks.com/loren/2009/04/14/convenient-nargout-behavior/#comment-30809</link>
		<dc:creator>OysterEngineer</dc:creator>
		<pubDate>Tue, 17 Nov 2009 22:39:24 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2009/04/14/convenient-nargout-behavior/#comment-30809</guid>
		<description>That helps some.  I see how the numel([c{1:0}0] is 0.

But, I haven't been able to invent a function, f, with no outputs such that nargout('f') or nargout(@f)is also 0.  I keep getting -1.</description>
		<content:encoded><![CDATA[<p>That helps some.  I see how the numel([c{1:0}0] is 0.</p>
<p>But, I haven&#8217;t been able to invent a function, f, with no outputs such that nargout(&#8217;f') or nargout(@f)is also 0.  I keep getting -1.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2009/04/14/convenient-nargout-behavior/#comment-30806</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Tue, 17 Nov 2009 19:24:32 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2009/04/14/convenient-nargout-behavior/#comment-30806</guid>
		<description>OysterEngineer-

When MATLAB goes to calcualate [c{1:0}] = f(…),
it is finding 0 elements on the left side (numel([c{1:0}]) IS 0) which IS nargout(f), and therefore f gets called as if nargout is 0.

--Loren</description>
		<content:encoded><![CDATA[<p>OysterEngineer-</p>
<p>When MATLAB goes to calcualate [c{1:0}] = f(…),<br />
it is finding 0 elements on the left side (numel([c{1:0}]) IS 0) which IS nargout(f), and therefore f gets called as if nargout is 0.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: OysterEngineer</title>
		<link>http://blogs.mathworks.com/loren/2009/04/14/convenient-nargout-behavior/#comment-30805</link>
		<dc:creator>OysterEngineer</dc:creator>
		<pubDate>Tue, 17 Nov 2009 19:18:49 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2009/04/14/convenient-nargout-behavior/#comment-30805</guid>
		<description>I understand that 1:0 is an empty matrix.

But, by what is happening with [c{1:0}] = f(...)

Is it really doing something like: [c{1:0}] = [] ?

Also, what do you mean when you say, "when called with an nargout is zero . . . ?"  The FRP is nicely clear in explaining that it can be called without an input argument to return the number of output arguments a user has supplied.  Or, it can be called with a function handle or a function name as an input argument to return the number of output arguments the function was written to provide.  So, which use are you referring to?</description>
		<content:encoded><![CDATA[<p>I understand that 1:0 is an empty matrix.</p>
<p>But, by what is happening with [c{1:0}] = f(&#8230;)</p>
<p>Is it really doing something like: [c{1:0}] = [] ?</p>
<p>Also, what do you mean when you say, &#8220;when called with an nargout is zero . . . ?&#8221;  The FRP is nicely clear in explaining that it can be called without an input argument to return the number of output arguments a user has supplied.  Or, it can be called with a function handle or a function name as an input argument to return the number of output arguments the function was written to provide.  So, which use are you referring to?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2009/04/14/convenient-nargout-behavior/#comment-30229</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Fri, 24 Apr 2009 16:35:23 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2009/04/14/convenient-nargout-behavior/#comment-30229</guid>
		<description>I'm delighted that several of you find good use in this nargout behavior.

--Loren</description>
		<content:encoded><![CDATA[<p>I&#8217;m delighted that several of you find good use in this nargout behavior.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kieran</title>
		<link>http://blogs.mathworks.com/loren/2009/04/14/convenient-nargout-behavior/#comment-30224</link>
		<dc:creator>Kieran</dc:creator>
		<pubDate>Thu, 23 Apr 2009 15:13:14 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2009/04/14/convenient-nargout-behavior/#comment-30224</guid>
		<description>Thanks Loren. This code really helped me in using subsref in my classes. I wanted to only change some subsref functionality and call the builtin version for the rest, but ran into output argument issues. I ended up doing something like:

function varargout = subsref(this, s)
  use_built_in = true;
  % Add custom subsref here and set use_built_in to false. 
  
  % Use default subsref for others.
  if use_built_in
     [varargout{1:nargout}] = builtin('subsref', this, s);
  end
end</description>
		<content:encoded><![CDATA[<p>Thanks Loren. This code really helped me in using subsref in my classes. I wanted to only change some subsref functionality and call the builtin version for the rest, but ran into output argument issues. I ended up doing something like:</p>
<p>function varargout = subsref(this, s)<br />
  use_built_in = true;<br />
  % Add custom subsref here and set use_built_in to false. </p>
<p>  % Use default subsref for others.<br />
  if use_built_in<br />
     [varargout{1:nargout}] = builtin(&#8217;subsref&#8217;, this, s);<br />
  end<br />
end</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sung Soo</title>
		<link>http://blogs.mathworks.com/loren/2009/04/14/convenient-nargout-behavior/#comment-30216</link>
		<dc:creator>Sung Soo</dc:creator>
		<pubDate>Tue, 21 Apr 2009 00:35:06 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2009/04/14/convenient-nargout-behavior/#comment-30216</guid>
		<description>I use similar technique to access subfunctions because I don't want to have many small functions in different m-files though 'class' can solve this too.</description>
		<content:encoded><![CDATA[<p>I use similar technique to access subfunctions because I don&#8217;t want to have many small functions in different m-files though &#8216;class&#8217; can solve this too.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Oliver Woodford</title>
		<link>http://blogs.mathworks.com/loren/2009/04/14/convenient-nargout-behavior/#comment-30209</link>
		<dc:creator>Oliver Woodford</dc:creator>
		<pubDate>Wed, 15 Apr 2009 15:41:46 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2009/04/14/convenient-nargout-behavior/#comment-30209</guid>
		<description>Useful. It allowed me to change:

&lt;pre&gt;
str = sprintf('"%s" %s', xpdf_path, cmd);
if nargout
    [varargout{:}] = system(str);
else
    system(str);
end
&lt;/pre&gt;

to:

&lt;pre&gt;
[varargout{1:nargout}] = system(sprintf('"%s" %s', xpdf_path, cmd));
&lt;/pre&gt;

Oliver</description>
		<content:encoded><![CDATA[<p>Useful. It allowed me to change:</p>
<pre>
str = sprintf('"%s" %s', xpdf_path, cmd);
if nargout
    [varargout{:}] = system(str);
else
    system(str);
end
</pre>
<p>to:</p>
<pre>
[varargout{1:nargout}] = system(sprintf('"%s" %s', xpdf_path, cmd));
</pre>
<p>Oliver</p>
]]></content:encoded>
	</item>
</channel>
</rss>
