run code sections in matlab R2017b.

when I run a code section, matlab R2017b now check for errors in the entire script, not just on the section to be executed (as it used to be in older versions). Is this a bug or is it in purpose?
I am using mac OS Sierra 10.12.6 (if that is of any relevance)
thanks. Claudio

댓글 수: 3

M
M 2017년 10월 30일
It is strange because I am also using Matlab 2017b and for me it is not the case.
Rik
Rik 2017년 10월 30일
I think it does check for syntax errors like unmatched parentheses, as those could affect what code should be run.
It is not a parenthesis mismatch or something similar. The following standard 2-section matlab example gives me error (use to work under R2016b). Thanks for any suggestion. Claudio
%%Calculate and Plot Sine Wave
x = 0:1:6*pi;
y = sin(x);
plot(x,y)
%%Modify Plot Properties
title('Sine Wave')
xlabel('x')
% ADD A SYNTAX ERROR IN PURPOSE
----------
ylabel('sin(x)')

댓글을 달려면 로그인하십시오.

답변 (1개)

Prasanth Sunkara
Prasanth Sunkara 2017년 11월 28일

0 개 추천

Hello Claudio,
This behavior is by design. Having this capability allows section evaluation to access local functions which seems desirable.
-Prasanth

댓글 수: 3

Claudio Altafini
Claudio Altafini 2017년 11월 28일
Hi Prasanth, thanks for the explanation. The weak side of the change is the following: sometimes one needs to run a section of code while the following sections are still incomplete/not yet debugged. If matlab checks grammar throughout, it becomes impossible to run single sections. To me this was the big advantage of command+enter. Back to old cut-and-paste.
regards
Claudio
Rik
Rik 2017년 11월 28일
You can use %{ and %} to comment out blocks of code (or you can use the comment out button in the editor lint).
I hadn't considered that it had something to do with in-script-functions (which I think will encourage horrible coding practices).
Chad Greene
Chad Greene 2018년 2월 28일
What a frustrating design change! Any chance we'll ever get a Preference option to change it back?

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Performance and Memory에 대해 자세히 알아보기

태그

질문:

2017년 10월 30일

댓글:

2018년 2월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by