how to find subsequences

3 visualizaciones (últimos 30 días)
pamela sulis
pamela sulis el 4 de Abr. de 2016
Respondida: Azzi Abdelmalek el 4 de Abr. de 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

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 4 de Abr. de 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}

Más respuestas (0)

Categorías

Más información sobre Data Types en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by