Effacer les filtres
Effacer les filtres

help with preallocating arrays?

1 vue (au cours des 30 derniers jours)
ME
ME le 10 Avr 2015
Modifié(e) : ME le 12 Avr 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

Réponses (1)

Roger Stafford
Roger Stafford le 10 Avr 2015
myArray = zeros(1,10);
for k = 1:10
myArray(k) = k+1;
end
or better still:
myArray = 2:11;

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by