Error: Unable to perform assignment because the left and right sides have a different number of elements.

 Respuesta aceptada

You are using a double for loop. I advise its best to use something like this
for ii=1:24
for jj=1:24
z(ii,jj)=normrnd(mu_SC(ii),std_SC(jj),1000);
end
end

3 comentarios

this solution threw a "unable to perform assignment because the indices on the left side are not compatible with the size of the right side."
Hello, from your question i think you are tring to generate a 1000x1000 array of normal random numbers, then in that case you can use cell notation, with curly brackets to the output as below:
for ii=1:24
for jj=1:24
z{ii,jj}=normrnd(mu_SC(ii),std_SC(jj),1000);
end
end
With preallocation to avoid inefficiency and some errors related to unmatching classes/types/sizes:
z = cell(24,24);
for ...
end

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 12 de Feb. de 2020

Editada:

el 13 de Feb. de 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by