Assignment has more non-singleton rhs dimensions than non-singleton subscripts
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
dpb
el 13 de Jul. de 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
el 13 de Jul. de 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.
Respuestas (0)
Ver también
Categorías
Más información sobre Workspace Variables and MAT Files en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!