<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264563</link>
    <title>MATLAB Central Newsreader - checking a function handle</title>
    <description>Feed for thread: checking a function handle</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Fri, 30 Oct 2009 14:36:31 -0400</pubDate>
      <title>checking a function handle</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264563#690960</link>
      <author>Mauro</author>
      <description>I want to check in an if statement if a function handle is equal to&lt;br&gt;
the identity @(x) 1. Is there any way for me to do that?&lt;br&gt;
&lt;br&gt;
Thanks.</description>
    </item>
    <item>
      <pubDate>Fri, 30 Oct 2009 14:53:30 -0400</pubDate>
      <title>Re: checking a function handle</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264563#690970</link>
      <author>Loren Shure</author>
      <description>In article &amp;lt;8e3b51f4-f830-42f3-ab71-3a7b97a643d6&lt;br&gt;
@p35g2000yqh.googlegroups.com&amp;gt;, msmscarlatti@googlemail.com says...&lt;br&gt;
&amp;gt; I want to check in an if statement if a function handle is equal to&lt;br&gt;
&amp;gt; the identity @(x) 1. Is there any way for me to do that?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks.&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
I'll show you how (with an undocumented function), but why do you want &lt;br&gt;
to check this? What if the user writes the identity as @(x) ones(1), or &lt;br&gt;
any other number of ways.  This seems possibly ill-conceived.&lt;br&gt;
&lt;br&gt;
You could use functions on the fh, and then get the function expression &lt;br&gt;
from there. &lt;br&gt;
&lt;br&gt;
x =  @(q) 1&lt;br&gt;
s = functions(x)&lt;br&gt;
x = &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@(q)1&lt;br&gt;
s = &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function: '@(q)1'&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;type: 'anonymous'&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;file: ''&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;workspace: {[1x1 struct]}&lt;br&gt;
&amp;gt;&amp;gt; s.function&lt;br&gt;
ans =&lt;br&gt;
@(q)1&lt;br&gt;
&lt;br&gt;
-- &lt;br&gt;
Loren&lt;br&gt;
&lt;a href=&quot;http://blogs.mathworks.com/loren&quot;&gt;http://blogs.mathworks.com/loren&lt;/a&gt;</description>
    </item>
    <item>
      <pubDate>Sat, 31 Oct 2009 17:12:02 -0400</pubDate>
      <title>Re: checking a function handle</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264563#691186</link>
      <author>Yair Altman</author>
      <description>Loren Shure &amp;lt;loren.shure@mathworks.com&amp;gt; wrote in message &amp;lt;MPG.2554c7f35cb14522989a5a@news.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; In article &amp;lt;8e3b51f4-f830-42f3-ab71-3a7b97a643d6&lt;br&gt;
&amp;gt; @p35g2000yqh.googlegroups.com&amp;gt;, msmscarlatti@googlemail.com says...&lt;br&gt;
&amp;gt; &amp;gt; I want to check in an if statement if a function handle is equal to&lt;br&gt;
&amp;gt; &amp;gt; the identity @(x) 1. Is there any way for me to do that?&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Thanks.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I'll show you how (with an undocumented function), but why do you want &lt;br&gt;
&amp;gt; to check this? What if the user writes the identity as @(x) ones(1), or &lt;br&gt;
&amp;gt; any other number of ways.  This seems possibly ill-conceived.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; You could use functions on the fh, and then get the function expression &lt;br&gt;
&amp;gt; from there. &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; x =  @(q) 1&lt;br&gt;
&amp;gt; s = functions(x)&lt;br&gt;
&amp;gt; x = &lt;br&gt;
&amp;gt;     @(q)1&lt;br&gt;
&amp;gt; s = &lt;br&gt;
&amp;gt;      function: '@(q)1'&lt;br&gt;
&amp;gt;          type: 'anonymous'&lt;br&gt;
&amp;gt;          file: ''&lt;br&gt;
&amp;gt;     workspace: {[1x1 struct]}&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; s.function&lt;br&gt;
&amp;gt; ans =&lt;br&gt;
&amp;gt; @(q)1&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; -- &lt;br&gt;
&amp;gt; Loren&lt;br&gt;
&amp;gt; &lt;a href=&quot;http://blogs.mathworks.com/loren&quot;&gt;http://blogs.mathworks.com/loren&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Actually, Loren, I believe that @functions is an entirely-documented function: it has both a help section (%matlabroot%\toolbox\matlab\datatypes\functions.m) and a doc-page. It even appears in the online version: &lt;a href=&quot;http://www.mathworks.com/access/helpdesk/help/techdoc/ref/functions.html&quot;&gt;http://www.mathworks.com/access/helpdesk/help/techdoc/ref/functions.html&lt;/a&gt; . Perhaps it was undocumented in some old release, but it's documented at least since R2008a.&lt;br&gt;
&lt;br&gt;
Yair Altman&lt;br&gt;
&lt;a href=&quot;http://UndocumentedMatlab.com&quot;&gt;http://UndocumentedMatlab.com&lt;/a&gt; &lt;br&gt;
&amp;nbsp;</description>
    </item>
  </channel>
</rss>

