Error evaluating sectioned code
20 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Chad Greene
el 27 de Feb. de 2018
Comentada: Chad Greene
el 28 de Feb. de 2018
I recently updated from R2014b to R2017b, and I've noticed a new, somewhat annoying behavior. In older versions of Matlab, I could section my code like this:
%%Section 1:
x = 1 + 2;
%%Section 2:
y = [5 ;
Sectioning code makes it easy to evaluate one chunk at a time, while I'm still working on other parts of the script. Just put the cursor anywhere in Section 1, hit Ctrl+Enter, and it'll evaluate everything in Section 1. However, R2017b now refuses to calculate anything unless the entire script is in perfect working order. If I try to evaluate Section 1 of the code above I get this error:
Error: File: test.m Line: 7 Column: 11
This statement is incomplete.
Yes, Matlab, I know. I'm still working on Section 2, but can I just evaluate Section 1? Is there any way to get the old behavior back?
0 comentarios
Respuesta aceptada
Rik
el 27 de Feb. de 2018
As far as I can tell, there is no way to turn this off. See also this question. The point is that if the syntax is incorrect in one section, Matlab can't enable local functions and apparently the editor is not smart enough to see that you don't have local functions in your script.
The only way I found is to comment out the section that have still an incorrect syntax (with %{ and %}, as I presume you are aware).
Local functions can be useful in debugging, but I don't know if I agree with the design principle. I'm not really using Matlab long enough to be old-fashioned, but I'm getting the feeling I am. I don't see the advantage of live scripts over sections either.
Más respuestas (0)
Ver también
Categorías
Más información sobre Get Started with MATLAB 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!