MATLAB: Make matrix from arrays with for loop

arrayfor looploopmatrixvector

Hello, I have the following problem:
array_1 = [1 2 3];
array_2 = [4 5 6];
array_3 = [7 8 9];
array_i = [.....];
I want to use a for loop to create one matrix looking like:
matrix =
1 2 3
4 5 6
7 8 9
.....
How can I realize that? Thanks, J.

Best Answer

%%create arrays
array_1 = [1 2 3];
array_2 = [4 5 6];
array_3 = [7 8 9];
array_4 = [1 2 3];
array_5 = [4 5 6];
array_6 = [7 8 9];
save myfile.mat ;
clearvars
S = load('myfile.mat') ;
names = fields(S) ;
iwant = zeros(length(names),3) ;
for i = 1:length(names)
iwant(i,:) = getfield(S,names{i}) ;
end