Deactivation switch for implicit expansion

조회 수: 4 (최근 30일)
Matt J
Matt J 2016년 12월 29일
댓글: Digital Guy 2021년 9월 28일
Does anyone know if there is a way to disable the implicit expansion feature introduced in R2016b?
  댓글 수: 4
Matt J
Matt J 2019년 1월 7일
편집: Matt J 2019년 1월 7일
Just to be clear, I was asking about this purely as a debugging tool. I am in favor of implicit expansion as a feature and hope it's here to stay.
Jan
Jan 2019년 1월 7일
Maybe running the code and exhaustive unit-tests in R2016a is the best option for debugging. It will not only reveal implicit expansion problems, but all other incompatibilities with older software also. Unfortunately this requires a conservative programming style, e.g. to avoid modern strings defined with double quotes.

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

채택된 답변

John D'Errico
John D'Errico 2018년 2월 20일
편집: John D'Errico 2018년 2월 20일
I believe it is not possible to disable the expansion. Personally, I like having it, just that people don't like change. There is some risk in implicit expansion, in that MATLAB novices will sometimes get hurt.
Now, could they introduce a settable flag, telling MATLAB to not use expansion? Yes, they surely could do so. The problem is then code written is no longer portable. Move your code to another computer that has the flag set off or on, and suddenly your code will not work. Or if your code sets the flag and someone uses your code, then suddenly you may have effectively introduced a bug into their code.
So, sorry but IMO, a flag or preference that can disable expansion is a bad idea.
Could you disable it yourself? I suppose you could overload the affected operators, checking for any case of implicit expansion. If you find it, then trap out with an error, saying that implicit expansion is just wrong in your humble opinion, and you won't allow it to work on your system. If no expansion is detected, then use the built-in operator. Yes, it will slow down your code. But it would work.
  댓글 수: 7
Chuck37
Chuck37 2019년 4월 29일
I just recently moved up to 2016B and implicit expansion is a nightmare. I write quick and dirty code for analysis and am getting burned by this. I'm not a "novice" at MATLAB by any stretch, but I have become accustomed to letting error messages guide me on trivial row vs. column situtations. I just spent an hour figuring out why I was getting the wrong answer from norm(a-b). It turns out, of course, that matlab was blowing a row/column mismatch out into a matrix. Ugh.

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

추가 답변 (1개)

Jan
Jan 2018년 2월 19일
I'm convinced, that there is no switch to disable it. Otherwise it would have been mentioned in the forum.
  댓글 수: 7
Walter Roberson
Walter Roberson 2018년 2월 27일
dbstop is a proposal not something implemented
KL
KL 2018년 2월 27일
Aha okay!

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

카테고리

Help CenterFile Exchange에서 Historical Contests에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by