MATLAB Editor bug? "There is no anonymous function"

Hi all,
consider a simple anonymous function:
f=@(x)x.^2
In a minimal example, I made a file which contains only this line. I then click on the left of the line to add a breakpoint. MATLAB Editor offers the choice: "Set breakpoint at beginning of line" or "Set breakpoint at anonymous function" . I choose "at anonymous function" and get the following error message:
"Cannot enable breakpoint(s) because of syntax error. There is no anonymous function on line 1 of file C:\...\tmp.m"
This is consistently reproducible with R2014b and R2015a and some earlier releases.
Why does MATLAB Editor offer to set a breakpoint at the anonymous function, and then doesn't manage to do so? Is it a bug? Is there a solution?
Thanks! V.

6 comentarios

John D'Errico
John D'Errico el 13 de Abr. de 2015
I had absolutely no problems here. My guess is there is something about the function you have saved, or where you saved it.
Adam
Adam el 13 de Abr. de 2015
I get the same problem when I tried it though I never use this functionality or know what it aims to do. I just always choose the beginning of line option for my anonymous functions anyway.
So it works for John but not for Adam... Which MATLAB versions are you folks using?
John D'Errico
John D'Errico el 13 de Abr. de 2015
2015a here
Stephen23
Stephen23 el 13 de Abr. de 2015
It happens with 2012b and 2009b too. Screenshot of 2012b:
Adam
Adam el 13 de Abr. de 2015
R2014b for me

Iniciar sesión para comentar.

Respuestas (1)

Robert Cumming
Robert Cumming el 13 de Abr. de 2015

0 votos

Its because your m file is in essence a script. Try creating a larger script and but a break point in the anonymous function and you will get the same result.
Convert script to a standard function file and it will work.
So I think it is a bug it shouldn't offer the ability to put a break point in an anonymous function which is saved as part of a script.

Categorías

Más información sobre Entering Commands en Centro de ayuda y File Exchange.

Productos

Preguntada:

el 13 de Abr. de 2015

Respondida:

el 13 de Abr. de 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by