Filter löschen
Filter löschen

how to find subsequences

3 Ansichten (letzte 30 Tage)
pamela sulis
pamela sulis am 4 Apr. 2016
Beantwortet: Azzi Abdelmalek am 4 Apr. 2016
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

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 4 Apr. 2016
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}

Weitere Antworten (0)

Kategorien

Mehr zu Data Types finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by