Borrar filtros
Borrar filtros

how to repeat [5,4,3,2,1.....] infinitely?

4 visualizaciones (últimos 30 días)
우재 민
우재 민 el 31 de Mzo. de 2022
Editada: Bruno Luong el 31 de Mzo. de 2022
how could I?
can someone give me a code?
  1 comentario
Rik
Rik el 31 de Mzo. de 2022
Your computer does not have infinite memory. What exactly did you intend to do with this infinite vector?

Iniciar sesión para comentar.

Respuestas (1)

Bruno Luong
Bruno Luong el 31 de Mzo. de 2022
Editada: Bruno Luong el 31 de Mzo. de 2022
A meta-array:
x = rep5to1(100:120)
x = 1×21
1 5 4 3 2 1 5 4 3 2 1 5 4 3 2 1 5 4 3 2 1
%%
function x = rep5to1(i)
a=5:-1:1;
x = a(mod(i-1,length(a))+1);
end

Categorías

Más información sobre Multidimensional Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by