필터 지우기
필터 지우기

how can i make a storage in simulation for matrix ?

조회 수: 1 (최근 30일)
arkedia
arkedia 2013년 2월 14일
i'm creating a simulation and the following is part of the code
for i=1:k
samples=ssvs(e,y,q,m,k)
z(i,:)=samples
end.......
note: e ,y ,q are variables and ssvs function will give a matrix of order m rows and q columnes i want z to store the results same as horzcat i mean i want z save first result then second then the next tell the simulation ends z order will be m*k rows and q columnes

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 2월 14일
편집: Azzi Abdelmalek 2013년 2월 14일
z=[];
for i=1:k
samples=ssvs(e,y,q,m,k);
z=[z samples ];
end
  댓글 수: 1
José-Luis
José-Luis 2013년 2월 14일
That might be painfully slow if you don't preallocate. Hard to do that if you do not know the size of samples in advance or if that size is not constant.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

José-Luis
José-Luis 2013년 2월 14일
편집: José-Luis 2013년 2월 14일
You should probably use a cell array:
my_result = cell(1,k);
for ii = 1:k
my_result{i} = ssvs(e,y,q,m,k);
end
And if you want a matrix, and dimensions allow:
your_mat = cell2mat(my_result);

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by