<?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: More on expansion: arrayfun</title>
	<link>http://blogs.mathworks.com/loren/2006/03/01/more-on-expansion-arrayfun/</link>
	<description>Loren Shure  works on design of the MATLAB language at The MathWorks. She writes here about once a week on MATLAB programming and related topics. </description>
	<pubDate>Sun, 07 Sep 2008 02:36:09 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.1</generator>
		<item>
		<title>By: StephenLL</title>
		<link>http://blogs.mathworks.com/loren/2006/03/01/more-on-expansion-arrayfun/#comment-26548</link>
		<dc:creator>StephenLL</dc:creator>
		<pubDate>Thu, 21 Feb 2008 13:27:38 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2006/03/01/more-on-expansion-arrayfun/#comment-26548</guid>
		<description>Dani,

The following maybe what you are looking for.
http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=16467&#38;objectType=FILE

I wrote it so I did not have to explicitly write loops or always write code that could take dim as an input.

The benefit is not speed but clear compact writing of code.

StephenLL</description>
		<content:encoded><![CDATA[<p>Dani,</p>
<p>The following maybe what you are looking for.<br />
<a href="http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=16467&amp;objectType=FILE" rel="nofollow">http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=16467&amp;objectType=FILE</a></p>
<p>I wrote it so I did not have to explicitly write loops or always write code that could take dim as an input.</p>
<p>The benefit is not speed but clear compact writing of code.</p>
<p>StephenLL</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2006/03/01/more-on-expansion-arrayfun/#comment-26546</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Thu, 21 Feb 2008 12:22:17 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2006/03/01/more-on-expansion-arrayfun/#comment-26546</guid>
		<description>Dani-

No, there is not function per se that works on each column.  However, many MATLAB functions do operate on columns such as sum, mean, fft.  You could write an anonymous function that takes a matrix and works on each column (using something like A(:,i) ).  If you have a detailed question, I recommend you contact technical support to help with the specific issues.

--Loren</description>
		<content:encoded><![CDATA[<p>Dani-</p>
<p>No, there is not function per se that works on each column.  However, many MATLAB functions do operate on columns such as sum, mean, fft.  You could write an anonymous function that takes a matrix and works on each column (using something like A(:,i) ).  If you have a detailed question, I recommend you contact technical support to help with the specific issues.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dani Hak</title>
		<link>http://blogs.mathworks.com/loren/2006/03/01/more-on-expansion-arrayfun/#comment-26541</link>
		<dc:creator>Dani Hak</dc:creator>
		<pubDate>Thu, 21 Feb 2008 08:09:25 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2006/03/01/more-on-expansion-arrayfun/#comment-26541</guid>
		<description>Hello Loren,

arrayfuncion works on each array element,
is there a function which operates on each colon?

Thanks,
Dani.</description>
		<content:encoded><![CDATA[<p>Hello Loren,</p>
<p>arrayfuncion works on each array element,<br />
is there a function which operates on each colon?</p>
<p>Thanks,<br />
Dani.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: StephenLL</title>
		<link>http://blogs.mathworks.com/loren/2006/03/01/more-on-expansion-arrayfun/#comment-61</link>
		<dc:creator>StephenLL</dc:creator>
		<pubDate>Wed, 01 Mar 2006 18:24:23 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2006/03/01/more-on-expansion-arrayfun/#comment-61</guid>
		<description>The approach recommended by Urs in Loren's previous blog entry, would yield something like: genopfun(x,y.','^') (if x and y were vectors) which is really nice and compact.  Simililar to R's outer function.  What makes the genop solution so nice is that rather then just vectors it would work along singleton dimensions as well.

Stephen</description>
		<content:encoded><![CDATA[<p>The approach recommended by Urs in Loren&#8217;s previous blog entry, would yield something like: genopfun(x,y.&#8217;,'^&#8217;) (if x and y were vectors) which is really nice and compact.  Simililar to R&#8217;s outer function.  What makes the genop solution so nice is that rather then just vectors it would work along singleton dimensions as well.</p>
<p>Stephen</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: A Brook</title>
		<link>http://blogs.mathworks.com/loren/2006/03/01/more-on-expansion-arrayfun/#comment-60</link>
		<dc:creator>A Brook</dc:creator>
		<pubDate>Wed, 01 Mar 2006 17:09:39 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2006/03/01/more-on-expansion-arrayfun/#comment-60</guid>
		<description>This is one point where Mathematica beats you. Their "Outer" is much cleaner and easier to use than this "arrayfun". 

Why can't we have Outer in Matlab? Then we can say 
Outer(@(a,b)a.^b,x,powers) -- so much easier, nicer, and keeping with Matlab Spirit.

Maybe you can somehow implement Outer with arrayfun?</description>
		<content:encoded><![CDATA[<p>This is one point where Mathematica beats you. Their &#8220;Outer&#8221; is much cleaner and easier to use than this &#8220;arrayfun&#8221;. </p>
<p>Why can&#8217;t we have Outer in Matlab? Then we can say<br />
Outer(@(a,b)a.^b,x,powers) &#8212; so much easier, nicer, and keeping with Matlab Spirit.</p>
<p>Maybe you can somehow implement Outer with arrayfun?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Petr Pošík</title>
		<link>http://blogs.mathworks.com/loren/2006/03/01/more-on-expansion-arrayfun/#comment-59</link>
		<dc:creator>Petr Pošík</dc:creator>
		<pubDate>Wed, 01 Mar 2006 13:32:55 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2006/03/01/more-on-expansion-arrayfun/#comment-59</guid>
		<description>Hi Loren. Thanks for introducing the arrayfun to me! I'm using SP2 so that I can't use them, but anyway...

Yes, this is a reasonable way of accomplishing the expansion. Similar constructs can be found in PERL (function map), etc.

But one reason for which I love MATLAB so much is the minimalism with which these things can be written. And I think the arrayfun is not the MATLAB way of doing it. Compare:

&#62; 5 + [6 7 8 9]

with

&#62; arrayfun(@(p)5+p,[6 7 8 9],'uniformoutput',true)

Of course, this is a stupid example, but I really do not know if I fell in love with MATLAB if I had to write the second type of commands. The difference when compared with FOR loops is not that big, and in my opinion, the FOR loops are for many programmers more intuitive because they are used to use them.</description>
		<content:encoded><![CDATA[<p>Hi Loren. Thanks for introducing the arrayfun to me! I&#8217;m using SP2 so that I can&#8217;t use them, but anyway&#8230;</p>
<p>Yes, this is a reasonable way of accomplishing the expansion. Similar constructs can be found in PERL (function map), etc.</p>
<p>But one reason for which I love MATLAB so much is the minimalism with which these things can be written. And I think the arrayfun is not the MATLAB way of doing it. Compare:</p>
<p>&gt; 5 + [6 7 8 9]</p>
<p>with</p>
<p>&gt; arrayfun(@(p)5+p,[6 7 8 9],&#8217;uniformoutput&#8217;,true)</p>
<p>Of course, this is a stupid example, but I really do not know if I fell in love with MATLAB if I had to write the second type of commands. The difference when compared with FOR loops is not that big, and in my opinion, the FOR loops are for many programmers more intuitive because they are used to use them.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
