Assignment has more non-singleton rhs dimensions than non-singleton subscripts
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
dpb
le 13 Juil 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
le 13 Juil 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.
Réponses (0)
Voir également
Catégories
En savoir plus sur Workspace Variables and MAT Files dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!