Borrar filtros
Borrar filtros

help with preallocating arrays?

1 visualización (últimos 30 días)
ME
ME el 10 de Abr. de 2015
Editada: ME el 12 de Abr. de 2015
i need help making making this preallocated array
myArray = []
variableArray = []
for i=1:10
variable = [1,2,3]
variableArray = [variable]
myArray = [myArray; variableArray]
end

Respuestas (1)

Roger Stafford
Roger Stafford el 10 de Abr. de 2015
myArray = zeros(1,10);
for k = 1:10
myArray(k) = k+1;
end
or better still:
myArray = 2:11;

Categorías

Más información sobre Creating and Concatenating Matrices 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