필터 지우기
필터 지우기

Vectors merging dynamically

조회 수: 1 (최근 30일)
Raviteja
Raviteja 2011년 9월 10일
I have the following code
1 for i=1:Lev
2 R=A{i};
3 UTRP = crqa(R,[],[],[],threshold);
4 TRPfeat=[TRPfeat; UTRP];
5 UTRP=0;
6 end
In line 4, I am increment row of a matrix dynamically as loop increases.
Is there any other efficient way to do this? I need fast calculation, because the above code taking long time to execute...

답변 (2개)

Andrei Bobrov
Andrei Bobrov 2011년 9월 10일
TRPfeat = cell2mat(cellfun(@(x)crqa(x,[],[],[],threshold),A(:),'un',0))

Jan
Jan 2011년 9월 12일
C = cell(1, Lev);
for i = 1:Lev
C{i} = crqa(A{i}, [], [], [], threshold);
end
TRPfeat = cat(2, C{:});
If Lev is large, the missing pre-allocation in CAT matters. Then use FEX: Cell2Vec.mex.

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by