Cannot have function in script, Matlab 2016b
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
ML
el 10 de Mayo de 2017
Comentada: ML
el 11 de Mayo de 2017
Hi!
I'm trying to run a script with a function declared in the bottom. This should work on 2016b version, but for me it doesn't. I have version 9.1.0.441655 (R2016b).
Why does this not work?
2 comentarios
Stephen23
el 10 de Mayo de 2017
Editada: Stephen23
el 10 de Mayo de 2017
@Martin Larsson: what exactly does "This should work... but for me it doesn't" mean? Do you get an incorrect result, or a warning message, or an error message, do you get an infinite loop, or does MATLAB become unresponsive, or does your computer catch fire? Would you like me to call the fire brigade for you?
If you do not tell us what "not working" actually means, we have to rely on our magical crystal balls to view your computer monitor. Sadly mine seems to be on the blink today.
PS: if you get an error message, please show us the complete error message. This means all of the red text.
Respuesta aceptada
Steven Lord
el 10 de Mayo de 2017
Are you trying to copy a segment of the script that includes the function definition and paste it into the Command Window, or right-clicking and selecting "Evaluate Selection"? That will not work, any more than pasting the code starting with the line that declares the function using the function keyword to the Command Window would. From the Release Notes in release R2016b for this feature:
" Note: If your script contains local functions, you cannot run code sections (also known as code cells) individually. The Run Section and Run and Advance buttons are disabled. To run the script, type the saved script name in the Command Window or click Run. You can run sections individually in live scripts containing local functions. "
Más respuestas (0)
Ver también
Categorías
Más información sobre Matrix Indexing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!