(Matlab2016b-student) I had to substitute an (4x1)-Matrix with a (4x4)-Matrix. The result should have been a failure, instead it gave me a (4x4)-Matrix as output. How is this possible, when it is mathematical incorrect? In version Matlab2015b it gave the "correct" output that it's a failure because of the different matrix dimensions.

 Akzeptierte Antwort

James Tursa
James Tursa am 8 Nov. 2016
Bearbeitet: James Tursa am 8 Nov. 2016

0 Stimmen

You don't show your code, but my guess is you did one of the element-wise operations that now has scalar expansion built in. E.g.,
(4x4) + (4x1)
The above will fail in earlier versions of MATLAB, but in R2016a it is automatically done as if you had invoked the bsxfun function with the @plus operation. See this link under "Implicit Expansion":
https://www.mathworks.com/help/matlab/release-notes.html

2 Kommentare

Natalija Brkic
Natalija Brkic am 8 Nov. 2016
clear; clc;
A = [2 -3 5 1; 1 0 0 -1; 0 -3 -1 2; 3 2 0 -1];
f = [-3; 1; -15; 5];
x = A\f
x = inv(A) * f
fp = A*x
p = (f - A) * x % the result of (f-A) is a (4x4)-Matrix (what should be wrong)
James Tursa
James Tursa am 9 Nov. 2016
So for this particular problem, attempting to do (f-A) is of course wrong and earlier versions of MATLAB would complain, but the latest version doesn't. Is that your point?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by