Number of elements must be the same??
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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
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?
Respuestas (1)
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.
0 comentarios
Ver también
Categorías
Más información sobre Matrix Indexing 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!