more help needed with function handles

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

more help needed with function handles

John W. Eaton
Administrator
Could someone please run the following test in a recent version of
Matlab and report the results?

Unpack the attached zip file, run Matlab and cd to the builtin-fh-tst
directory created by unpacking the zip file.  Then execute tstscript and
post or send the resulting diary file to me.

Thanks,

jwe

builtin-fh-tst.zip (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: more help needed with function handles

nrjank

Unpack the attached zip file, run Matlab and cd to the builtin-fh-tst
directory created by unpacking the zip file.  Then execute tstscript and
post or send the resulting diary file to me.

matlab 2019a, diary file attached. 
Reply | Threaded
Open this post in threaded view
|

Re: more help needed with function handles

mmuetzel
In reply to this post by John W. Eaton
Am 25. März 2020 um 17:39 Uhr schrieb "John W. Eaton":
> Could someone please run the following test in a recent version of
> Matlab and report the results?
>
> Unpack the attached zip file, run Matlab and cd to the builtin-fh-tst
> directory created by unpacking the zip file.  Then execute tstscript and
> post or send the resulting diary file to me.

The attached file is the diary running the script with Matlab R2019b.

Markus
Reply | Threaded
Open this post in threaded view
|

Re: more help needed with function handles

Marco Caliari-4
In reply to this post by John W. Eaton
On Wed, 25 Mar 2020 12:39:05 -0400
"John W. Eaton" <[hidden email]> wrote:

> Could someone please run the following test in a recent version of
> Matlab and report the results?
>
> Unpack the attached zip file, run Matlab and cd to the builtin-fh-tst
> directory created by unpacking the zip file.  Then execute tstscript
> and post or send the resulting diary file to me.
>
> Thanks,
>
> jwe
Attached.

Marco

--
Dr. Marco Caliari
Dipartimento di Informatica
Universita` degli Studi di Verona
Secondo piano, 2.03
Ca' Vignal 2
Strada le Grazie 15
37134 VERONA

tel: +39 045 802 7904
fax: +39 045 802 7068

Le informazioni trasmesse sono intese soltanto per la persona o l'ente
cui sono indirizzate e possono avere contenuto confidenziale e/o
riservato. La visione, la trasmissione, la diffusione o altro uso delle
informazioni di cui sopra e` proibita a chiunque ad esclusione del
legittimo destinatario. Se avete ricevuto queste informazioni per
errore, siete pregati di contattare il mittente e cancellare il
materiale ricevuto.

The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited. If you
received this in error, please contact the sender and delete the
material from any computer.
Reply | Threaded
Open this post in threaded view
|

Re: more help needed with function handles

John W. Eaton
Administrator
In reply to this post by nrjank
Thanks for the responses.

It seems a little strange to me that after changing to subdir where
there is a sin.m file, Matlab is warning that the presence of that file
could cause trouble and which ('sin') finds the sin.m file but sin(pi)
calls the built-in function!

Now I'm curious to know whether the behavior is different if you enter
the commands one at a time at the command line instead of executing the
script file?  Also, what happens if you add a 'clear functions' command
just after changing to the subdir directory?

Maybe I need to try with a different function instead of sin, which I
suppose is not defined as a generic function but as a method for @double
and @single objects?  That would explain why it is found ahead of the .m
file.

jwe

Reply | Threaded
Open this post in threaded view
|

Re: more help needed with function handles

mmuetzel
Am 25. März 2020 um 18:43 Uhr schrieb "John W. Eaton":

> Thanks for the responses.
>
> It seems a little strange to me that after changing to subdir where
> there is a sin.m file, Matlab is warning that the presence of that file
> could cause trouble and which ('sin') finds the sin.m file but sin(pi)
> calls the built-in function!
>
> Now I'm curious to know whether the behavior is different if you enter
> the commands one at a time at the command line instead of executing the
> script file?
Same result (diary2)

>  Also, what happens if you add a 'clear functions' command
> just after changing to the subdir directory?

"diary3" was executed as a script with that addition.
"diary4" was executed line by line.

No difference.

> Maybe I need to try with a different function instead of sin, which I
> suppose is not defined as a generic function but as a method for @double
> and @single objects?  That would explain why it is found ahead of the .m
> file.

It is surprisingly hard to find a built-in function that accepts a double input that is not implemented as a class method.
I finally tried with "isstr" (diary5). I hope that helps.

Markus

diary2 (1K) Download Attachment
diary3 (1K) Download Attachment
diary4 (1K) Download Attachment
diary5 (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: more help needed with function handles

mmuetzel
Am 25. März 2020 um 19:37 Uhr schrieb "Markus Mützel":

> Am 25. März 2020 um 18:43 Uhr schrieb "John W. Eaton":
> > Thanks for the responses.
> >
> > It seems a little strange to me that after changing to subdir where
> > there is a sin.m file, Matlab is warning that the presence of that file
> > could cause trouble and which ('sin') finds the sin.m file but sin(pi)
> > calls the built-in function!
> >
> > Now I'm curious to know whether the behavior is different if you enter
> > the commands one at a time at the command line instead of executing the
> > script file?
> Same result (diary2)
>
> >  Also, what happens if you add a 'clear functions' command
> > just after changing to the subdir directory?
>
> "diary3" was executed as a script with that addition.
> "diary4" was executed line by line.
>
> No difference.
>
> > Maybe I need to try with a different function instead of sin, which I
> > suppose is not defined as a generic function but as a method for @double
> > and @single objects?  That would explain why it is found ahead of the .m
> > file.
>
> It is surprisingly hard to find a built-in function that accepts a double input that is not implemented as a class method.
> I finally tried with "isstr" (diary5). I hope that helps.
And another one without the "clear functions" (diary6).

> Markus

diary6 (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: more help needed with function handles

John W. Eaton
Administrator
On 3/25/20 2:42 PM, "Markus Mützel" wrote:

>> It is surprisingly hard to find a built-in function that accepts a double input that is not implemented as a class method.
>> I finally tried with "isstr" (diary5). I hope that helps.

We could also try with an argument that is something other than double.

> And another one without the "clear functions" (diary6).

I don't see any difference between those last two cases other than the
"clear functions" command (which is fine).

I think I see what's happening now.  Thanks.

It's interesting that functions (@sin) shows an empty "file" field but
functions (@isstr) says "MATLAB built-in function".  Also, sin is shown
as being a builtin in @double, but isstr is not in an '@' directory (not
that they are actually there, I suppose it is just a convention for
marking built-in functions with the classes they accept).

Octave already has a way to mark built-in functions with the classes
they accept but only a few functions are tagged so far.  For example, in
libinterp/corefcn/svd.cc:


   DEFUN (svd, args, nargout,
          classes: double single
          doc: /* -*- texinfo -*-
          ...

the "classes:" line is used to insert the "double" and "single" class
names in a table that is later used when searching for functions.  The
"sin" function in Octave is not marked this way.  So if you execute the
original test in Octave, it will do something different from Matlab, but
if you change the test to use svd instead of sin, it will be closer to
(I think maybe the same as) what Matlab does.

jwe