(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.

 Respuesta aceptada

James Tursa
James Tursa el 8 de Nov. de 2016
Editada: James Tursa el 8 de Nov. de 2016
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 comentarios

Natalija Brkic
Natalija Brkic el 8 de Nov. de 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 el 9 de Nov. de 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?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Etiquetas

Preguntada:

el 8 de Nov. de 2016

Comentada:

el 9 de Nov. de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by