Look and Say Sequence (Morris Sequence)

I am trying to implement the following sequence into Matlab using loops. The sequence is generated as follows:
V1=(1) Because it reads off V1 as "one 1" or "11"
Hence V2=(1,1)
V3=(2,1) Because it reads off V2 as "two ones" or "21"
Hence V4=(1,2,1,1) Because it reads off V3 as "one two one one" or "1211"
The sequence continues indefinitely
How can I write a script to produce this using "for" loops rather than the in-built functions?
Hence the sequence is (1),(1,1),(2,1),(1,2,1,1) and so on...

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Preguntada:

el 11 de Oct. de 2017

Respondida:

el 12 de Oct. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by