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

3 次查看(过去 30 天)
how could I?
can someone give me a code?
  1 个评论
Rik
Rik 2022-3-31
Your computer does not have infinite memory. What exactly did you intend to do with this infinite vector?

请先登录,再进行评论。

回答(1 个)

Bruno Luong
Bruno Luong 2022-3-31
编辑:Bruno Luong 2022-3-31
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

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by