Up down counter in command line

Is there a simple way to create an up down counter in command line or simple script/function?
Specifically, how can we create vectors such as [...1 2 3 3 2 1 1 2 3...], and more generally for any integers instead of 1 and 3?

Respuestas (1)

darova
darova el 9 de Mzo. de 2020
Example
n = 3;
sample = [1:n flip(1:n)];
vector = repmat(sample,[1 3]);

Categorías

Más información sobre MATLAB en Centro de ayuda y File Exchange.

Preguntada:

el 9 de Mzo. de 2020

Respondida:

el 9 de Mzo. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by