I want to assign some values to a matrix in a loop, but I don't know how many. B
is a vector that's calculated based on a data set Data(i,:)
inside a loop. The number of elements in B
is fixed inside the loop, but is unknown beforehand.
It is like;
A = zeros(n,m) %// I know n but I do not know m
for i = 1 : n
% some code to calculate B from Data(i,:)
A(i,:) = B;
end
B
is a vector, but I don't know length(B)
before the loop so I can't assign it to m
.
When I initialize A = [];
, Matlab gives a warning
A
appears to change size in every loop iteration.