フィルターのクリア

how to find subsequences

3 ビュー (過去 30 日間)
pamela sulis
pamela sulis 2016 年 4 月 4 日
回答済み: Azzi Abdelmalek 2016 年 4 月 4 日
Hi! I have
a={'1' '631' '618' '574' '678'}
and I want to find all possible sequences:
{'1'}
{'1' '631'}
{'1' '631' '618'}
{'1' '631' '618' '574'}
{'1' '631' '618' '574' '678'}
{'631'}
{'631' '618'}
{'631' '618' '574'}
{'631' '618' '574' '678'}
{'618'}
{'618' '574'}
{'618' '574' '678'}
{'574'}
{'574' '678'}
{'678'}
how can I do? thanks

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 4 月 4 日
a={'1' '631' '618' '574' '678'}
n=numel(a)
for k=1:n
b{k}=arrayfun(@(x) k:x,k:n,'un',0)
end
c=[b{:}]'
out=cellfun(@(x) a(x),c,'un',0)
out{1}
out{2}
out{3}

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Types についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by