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...

Catégories

En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by