Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Matrix in a for loop

2 visualizaciones (últimos 30 días)
Abed
Abed el 5 de Dic. de 2014
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
How could you add items into a matrix within a for loop without having to do stuff like this:
matrix(i,1) = [i ;];
matrix(i,2) = [a(i);];
matrix(i,3) = [b(i);];
matrix(i,4) = [Rsquared_eff(i);];
matrix(i,5) = [z(i);];
matrix(i,6) = [t(i);];
matrix(i,7) = [Rsquared_tox(i);];

Respuestas (1)

Star Strider
Star Strider el 5 de Dic. de 2014
This is how I would do it:
for k1 = 1:n
matrix(:,k1) = [k1; a(k1); b(k1); Rsquared_eff(k1); z(k1); t(k1); Rsquared_tox(k1)];
end
I changed the loop counter to ‘k1’ because MATLAB uses i and j for its imaginary operators. Using them as loop counters can create confusion.

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by