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

 채택된 답변

James Tursa
James Tursa 2016년 11월 8일
편집: James Tursa 2016년 11월 8일

0 개 추천

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

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 2016년 11월 9일
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?

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

질문:

2016년 11월 8일

댓글:

2016년 11월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by