Matlab 2016b Matrix Dimensions for addition and subtraction?

1 view (last 30 days)
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

Accepted Answer

James Tursa
James Tursa on 10 Oct 2016
Edited: James Tursa on 10 Oct 2016
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 Comment
Michael
Michael on 11 Oct 2016
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.

Sign in to comment.

More Answers (0)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!