Assignment has more non-singleton rhs dimensions than non-singleton subscripts
1 view (last 30 days)
Show older comments
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 Comments
dpb
on 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
on 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.
Answers (0)
See Also
Categories
Find more on Workspace Variables and MAT Files in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!