Matlab 2016b Matrix Dimensions for addition and subtraction?

조회 수: 1 (최근 30일)
Michael
Michael 2016년 10월 10일
댓글: Michael 2016년 10월 11일
In previous version of Matlab if I type:
>> a = [1 2; 3 4]; >> b = [1;3];
and then attempt to execute:
>> a - b
I get an error (as I should) because the matrix dimensions don't agree.
However, if I attempt this in 2016b I get:
>> a-b
ans =
0 1
0 1
Is this a new feature? Is this seen as an improvement? If so, can I turn this off? I feel this is dangerous.
Thanks,
-mcd

채택된 답변

James Tursa
James Tursa 2016년 10월 10일
편집: James Tursa 2016년 10월 10일
Yes, this is a new feature and is intentional. See this link under Implicit Expansion:
I don't see anything in the release notes that indicates you can shut this off. It is basically bsxfun that has now been implemented directly into the language.
  댓글 수: 1
Michael
Michael 2016년 10월 11일
Thanks for the response. I can see how this could be convenient in some situations, but it can lead to very weird results that could be hard to debug.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by