How to merge matrices generated from a for loop into one matrix.
Mostrar comentarios más antiguos
k = 4:.05:6.90
ElementNum = numel(k)
results = zeros(3,numel(k))
for w = 1:numel(k)
A(1,1) = k(w)
solution = rref(A)
solutionV = solution(:,4)
end
The above code is what I have written. I am trying to merge all the solutionV matrices into one matrix. How do I do this?
Respuestas (1)
James Tursa
el 27 de Abr. de 2017
Editada: James Tursa
el 27 de Abr. de 2017
E.g., as a matrix of columns:
solutionV = zeros(___,numel(k)); % <-- fill this in to pre-allocate
:
solutionV(:,w) = solution(:,4);
2 comentarios
patrick brannan
el 27 de Abr. de 2017
James Tursa
el 27 de Abr. de 2017
That last line was supposed to be obvious that it was inside the loop. E.g.,
k = 4:.05:6.90
ElementNum = numel(k)
results = zeros(3,numel(k))
solutionV = zeros(3,numel(k)); % <-- Pre-allocate
for w = 1:numel(k)
A(1,1) = k(w)
solution = rref(A)
solutionV(:,w) = solution(:,4); % <-- save as w'th column
end
Categorías
Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!