row filtering and pre-allocate

3 ビュー (過去 30 日間)
Oday Shahadh
Oday Shahadh 2020 年 6 月 10 日
コメント済み: madhan ravi 2020 年 6 月 10 日
hi all,
here p is (1,3) vector,:
  1. how can I preallocate a.
  2. how can store each filtered rows in a seperate matrix.
Regards
for i=1:length(L);
a=p(p(:,3)==L(i),:);
end

採用された回答

madhan ravi
madhan ravi 2020 年 6 月 10 日
編集済み: madhan ravi 2020 年 6 月 10 日
a = cell(numel(L),1);
for ii = 1:numel(L);
a{ii} = p(p(:,3) == L(ii),:);
end
celldisp(a)
%or
a = num2cell(p(any(p(:,3) == L, 2), :),2)
  2 件のコメント
Oday Shahadh
Oday Shahadh 2020 年 6 月 10 日
how can I edit each matrix, typed a(1) showed just its size
a(1)
ans =
[185x3 double]
madhan ravi
madhan ravi 2020 年 6 月 10 日

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePerformance and Memory についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by