Number of elements must be the same??

3 visualizaciones (últimos 30 días)
Kevin
Kevin el 9 de Jul. de 2014
Comentada: the cyclist el 9 de Jul. de 2014
Hi,
When running my Matlab programme, I am storing the desired values at the bottom of a for loop. The loop iterates for increasing values of i. However I am getting the following error:
In an assignment A(I) = B, the number of elements in B and I must be the same.
Error in BEM (line 95)
store_Phi(i)=Phi;
Can anybody please help me with this as I am not sure what this means?
Thanks,
Kevin
  1 comentario
the cyclist
the cyclist el 9 de Jul. de 2014
This is impossible to diagnose, given the amount of info you have given. Are you able to boil down your code into a short example that we can run ourselves, and that exhibits the error?
You might also benefit reading this page on debugging.

Iniciar sesión para comentar.

Respuestas (1)

dpb
dpb el 9 de Jul. de 2014
store_Phi(i) is a single value in the array and your result Phi is an array of some dimension. If this is intended, then you must have an addressing expression on the LHS of the assignment that matches in size that of the RHS.
I'll presume Phi is a column vector and you're building a 2D array of those columns...then the assignment would look like--
store_Phi(:,i)=Phi; % store ith column, all rows.
Rearrange the subscripts if row-vector, obviously.
You'll want to have preallocated the result array before the loop, of course.

Categorías

Más información sobre Logical 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!

Translated by