<?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 for Loren on the Art of MATLAB</title>
	<link>http://blogs.mathworks.com/loren</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>Sat, 07 Nov 2009 18:42:05 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.1</generator>
		<item>
		<title>Comment on Calculus with Empty Arrays by Loren</title>
		<link>http://blogs.mathworks.com/loren/2009/11/04/calculus-with-empty-arrays/#comment-30736</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Fri, 06 Nov 2009 11:50:59 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2009/11/04/calculus-with-empty-arrays/#comment-30736</guid>
		<description>Ben-

The reference link in my post documents the behavior of sum([]) and prod([]) (although the prod part only says the result is nonzero value).

--Loren</description>
		<content:encoded><![CDATA[<p>Ben-</p>
<p>The reference link in my post documents the behavior of sum([]) and prod([]) (although the prod part only says the result is nonzero value).</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Calculus with Empty Arrays by Ben</title>
		<link>http://blogs.mathworks.com/loren/2009/11/04/calculus-with-empty-arrays/#comment-30735</link>
		<dc:creator>Ben</dc:creator>
		<pubDate>Fri, 06 Nov 2009 07:52:00 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2009/11/04/calculus-with-empty-arrays/#comment-30735</guid>
		<description>Loren/Andrey,

A further advantage of having sum([])==0 and prod([])==1 is that it's consistent with array concatenation, e.g. prod([A;B]) and (prod(A).*prod(B)) remain equal when A or B are empty.

I often find sum([]) and prod([]) useful, but the help documents are strangely silent on their treatment.  Is it unofficial/unsupported functionality because of the controversy, or just something that was forgotten to be mentioned in the help docs?</description>
		<content:encoded><![CDATA[<p>Loren/Andrey,</p>
<p>A further advantage of having sum([])==0 and prod([])==1 is that it&#8217;s consistent with array concatenation, e.g. prod([A;B]) and (prod(A).*prod(B)) remain equal when A or B are empty.</p>
<p>I often find sum([]) and prod([]) useful, but the help documents are strangely silent on their treatment.  Is it unofficial/unsupported functionality because of the controversy, or just something that was forgotten to be mentioned in the help docs?</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Calculus with Empty Arrays by Loren</title>
		<link>http://blogs.mathworks.com/loren/2009/11/04/calculus-with-empty-arrays/#comment-30734</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Thu, 05 Nov 2009 15:42:40 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2009/11/04/calculus-with-empty-arrays/#comment-30734</guid>
		<description>OysterEngineer-

I will SO take you up on that offer.  Can't wait for a good reason to visit now.  Especially if the shucking tools are around as well :-)

--Loren</description>
		<content:encoded><![CDATA[<p>OysterEngineer-</p>
<p>I will SO take you up on that offer.  Can&#8217;t wait for a good reason to visit now.  Especially if the shucking tools are around as well :-)</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Calculus with Empty Arrays by OysterEngineer</title>
		<link>http://blogs.mathworks.com/loren/2009/11/04/calculus-with-empty-arrays/#comment-30733</link>
		<dc:creator>OysterEngineer</dc:creator>
		<pubDate>Thu, 05 Nov 2009 15:40:37 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2009/11/04/calculus-with-empty-arrays/#comment-30733</guid>
		<description>You know, I really do farm oysters part time.  Give me some advance notice next time you are in this part of the world &#38; I'll give you a tour of the beach.</description>
		<content:encoded><![CDATA[<p>You know, I really do farm oysters part time.  Give me some advance notice next time you are in this part of the world &amp; I&#8217;ll give you a tour of the beach.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Calculus with Empty Arrays by Loren</title>
		<link>http://blogs.mathworks.com/loren/2009/11/04/calculus-with-empty-arrays/#comment-30732</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Thu, 05 Nov 2009 13:24:35 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2009/11/04/calculus-with-empty-arrays/#comment-30732</guid>
		<description>Andrey-

Thanks for your thoughts.  

One way to think about why empty shouldn't error for sum is the following.  Suppose I have a list of some entities.  And I want the sum for all the ones greater than a certain value, say 0.  That list may be empty, but the sum is then 0.  Works for me without having to special case code then.

--Loren</description>
		<content:encoded><![CDATA[<p>Andrey-</p>
<p>Thanks for your thoughts.  </p>
<p>One way to think about why empty shouldn&#8217;t error for sum is the following.  Suppose I have a list of some entities.  And I want the sum for all the ones greater than a certain value, say 0.  That list may be empty, but the sum is then 0.  Works for me without having to special case code then.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Calculus with Empty Arrays by Andrey</title>
		<link>http://blogs.mathworks.com/loren/2009/11/04/calculus-with-empty-arrays/#comment-30731</link>
		<dc:creator>Andrey</dc:creator>
		<pubDate>Thu, 05 Nov 2009 13:02:46 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2009/11/04/calculus-with-empty-arrays/#comment-30731</guid>
		<description>Hi Loren!

IMHO, sum([]) and prod([]) should throw an error, as most of the times it shows that some kind of error happened before and somehow the variable became unexpectedly empty.

It is very much like asking to calculate the sum of a string.
:)</description>
		<content:encoded><![CDATA[<p>Hi Loren!</p>
<p>IMHO, sum([]) and prod([]) should throw an error, as most of the times it shows that some kind of error happened before and somehow the variable became unexpectedly empty.</p>
<p>It is very much like asking to calculate the sum of a string.<br />
:)</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Calculus with Empty Arrays by Loren</title>
		<link>http://blogs.mathworks.com/loren/2009/11/04/calculus-with-empty-arrays/#comment-30730</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Thu, 05 Nov 2009 12:14:30 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2009/11/04/calculus-with-empty-arrays/#comment-30730</guid>
		<description>OysterEngineer (love the name, by the way!)-

Initializing with an empty to start a concatenation process makes lots of sense and is good coding style in cases where you can't predetermine the final size, and therefore preallocate.

--Loren</description>
		<content:encoded><![CDATA[<p>OysterEngineer (love the name, by the way!)-</p>
<p>Initializing with an empty to start a concatenation process makes lots of sense and is good coding style in cases where you can&#8217;t predetermine the final size, and therefore preallocate.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Calculus with Empty Arrays by Loren</title>
		<link>http://blogs.mathworks.com/loren/2009/11/04/calculus-with-empty-arrays/#comment-30729</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Thu, 05 Nov 2009 12:13:05 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2009/11/04/calculus-with-empty-arrays/#comment-30729</guid>
		<description>Wes-

Implicitly there are trailing 1 dimensions for all arrays in MATLAB.  But they do get dropped by ndims, for example, after dimension 2.  So it can trip up code like you have seen.

--Loren</description>
		<content:encoded><![CDATA[<p>Wes-</p>
<p>Implicitly there are trailing 1 dimensions for all arrays in MATLAB.  But they do get dropped by ndims, for example, after dimension 2.  So it can trip up code like you have seen.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Calculus with Empty Arrays by Loren</title>
		<link>http://blogs.mathworks.com/loren/2009/11/04/calculus-with-empty-arrays/#comment-30728</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Thu, 05 Nov 2009 12:11:43 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2009/11/04/calculus-with-empty-arrays/#comment-30728</guid>
		<description>Janti-

Check out the function bsxfun.  It will do exactly what you are hoping - not expanding vectors to arrays in order to add different constants to each column, for example.

--Loren</description>
		<content:encoded><![CDATA[<p>Janti-</p>
<p>Check out the function bsxfun.  It will do exactly what you are hoping - not expanding vectors to arrays in order to add different constants to each column, for example.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Calculus with Empty Arrays by Wes</title>
		<link>http://blogs.mathworks.com/loren/2009/11/04/calculus-with-empty-arrays/#comment-30727</link>
		<dc:creator>Wes</dc:creator>
		<pubDate>Thu, 05 Nov 2009 11:14:59 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2009/11/04/calculus-with-empty-arrays/#comment-30727</guid>
		<description>I generally find MATLAB's handling of empties to be fairly consistent. It helps to think of an M-by-N array as an M-by-N-by-1-by-1-by-... array, where size() just truncates the infinite trailing ones. To this end, you can define a function like sizex:
&lt;pre&gt;
function s=sizex(x);s=size(x);s(end+1:5)=1;
&lt;/pre&gt;

This highlights the occasional case of the 0-by-0-by-1-by-... empty being considered somehow superior to other empties. Consider this sequence:
&lt;pre&gt;
sizex( num2cell( zeros( 3, 1 ) ) ) = [3 1 1 1 1]
sizex( num2cell( zeros( 2, 1 ) ) ) = [2 1 1 1 1]
sizex( num2cell( zeros( 1, 1 ) ) ) = [1 1 1 1 1]
sizex( num2cell( zeros( 0, 1 ) ) ) = [0 0 1 1 1]  % expected: [0 1 1 1 1]
&lt;/pre&gt;

This num2cell quirk often trips up my code and forces me to insert special-case handling for empties.</description>
		<content:encoded><![CDATA[<p>I generally find MATLAB&#8217;s handling of empties to be fairly consistent. It helps to think of an M-by-N array as an M-by-N-by-1-by-1-by-&#8230; array, where size() just truncates the infinite trailing ones. To this end, you can define a function like sizex:</p>
<pre>
function s=sizex(x);s=size(x);s(end+1:5)=1;
</pre>
<p>This highlights the occasional case of the 0-by-0-by-1-by-&#8230; empty being considered somehow superior to other empties. Consider this sequence:</p>
<pre>
sizex( num2cell( zeros( 3, 1 ) ) ) = [3 1 1 1 1]
sizex( num2cell( zeros( 2, 1 ) ) ) = [2 1 1 1 1]
sizex( num2cell( zeros( 1, 1 ) ) ) = [1 1 1 1 1]
sizex( num2cell( zeros( 0, 1 ) ) ) = [0 0 1 1 1]  % expected: [0 1 1 1 1]
</pre>
<p>This num2cell quirk often trips up my code and forces me to insert special-case handling for empties.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
