how to find subsequences

3 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Data Types 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by