Assignment has more non-singleton rhs dimensions than non-singleton subscripts

조회 수: 1 (최근 30일)
mathn00b
mathn00b 2017년 7월 12일
댓글: Walter Roberson 2017년 7월 13일
Can someone help me with this expression and the following error message?
Expression:
A(i:n, i)=(A(i:n, i-1) - A(i-1:n-1, i-1)) ./ (x(i:n) - x(1:n-i+1));
Error Message:
Assignment has more non-singleton rhs dimensions than non-singleton subscripts
I cannot find the reason, why Mathlab is complaining.
Thanks in advance for helping me :)
  댓글 수: 2
dpb
dpb 2017년 7월 13일
Show us what
whos A x
returns as well i, n.
Then try
tmp=(A(i:n, i-1) - A(i-1:n-1, i-1)) ./ (x(i:n) - x(1:n-i+1));
without the assignment and then what is
whos tmp % ?
That should answer the question. I'm guessing there's an implicit expansion going on from a combination of a column (A reference) and row (x reference) but I can't test what happens in later releases here after implicit expansion was implemented...
Walter Roberson
Walter Roberson 2017년 7월 13일
dpb is correct. If x is a row vector then (x(i:n) - x(1:n-i+1)) would be a row vector. (A(i:n, i-1) - A(i-1:n-1, i-1)) would be a column vector. If you are using R2016b or later, combining a row vector and a column vector with ./ would get you a 2D array as a result.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Workspace Variables and MAT Files에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by