How to store all results in vector, after "for-.......-end" code?

Hello, to all, many thanks for te possibility to learn more about MatLab through this forum and your shared experience! I would like to know how to store the individual results (which are arrays of 3x1 number) in the common array (vector with dimension of i*3x1). I am asking this because after "for-end" cycles only the last result is available fot further calculation. Any oppinion is highly appreciated! Regards!

 채택된 답변

Wayne King
Wayne King 2012년 3월 1일
Are you sure you don't want to save them as columns in a matrix like this:
N = 5;
X = zeros(3,5);
for nn = 1:5
X(:,nn) = randn(3,1);
end
If you really wanted them in one long column vector:
X = zeros(5*3,1);
for k = 0:4
X(k*3+1:(k+1)*3) = randn(3,1);
end

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 MATLAB Parallel Server에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by