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

1 Ansicht (letzte 30 Tage)
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 Kommentare
dpb
dpb am 13 Jul. 2017
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 am 13 Jul. 2017
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.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Workspace Variables and MAT Files finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by