MATLAB: Nested loop – storing vectors into matrix

for loopvectors into matrix

Hello,
I would like to store each vector from a loop a matrix (27 rows).
The current code creates the 27 vectors but overwrites previous vectors. How I can save the vector from each run into a matrix? The file exchange demo solution does not work.
%% ONLINE VERSION
clear all
% Random numbers in vector
r = random('Uniform',1,10,1,10);
u = sort(r) % here redundant
% Fixed parameters
k = 1;
l = 1;
m = 1;
% Creating a matrix based on vectors for each parameter change
a = [0 1 2];
b = [0 1 2];
c = [0 1 2];
% Vector with parameter a_i, b_i, c_i
% Creating loop
for i=1:length(a)
for j=1:length(b)
for f=1:length(c)
xDL = k + a(i) + (l + b(j))*u*(m + c(f))
lxDL = [xDL a(i) b(j) c(f)]
end
end
end
Thanks!

Best Answer

Before the loop, set
lxDL = [];
Change
lxDL = [xDL a(i) b(j) c(f)]
to
lxDL = [lxDL; xDl a(i) b(j) c(f)];