如何利用循环每次取一个数组的前几项?。

例如,A=[1:2000];如何利用循环体,循环第一次取A的前50个数,循环第二次取A的前100个数,循环第三次取A的前150个数,………………直至取完A中的数?请教大神指点。

 Respuesta aceptada

wakavep
wakavep el 17 de Nov. de 2022

0 votos

AA=arrayfun(@(x) a(1:x+50),0:50:2000,'un',0)
得到的是一个cell。
利用循环:
for k=0:50:2000
AA=A(1:k+50)
end
得到的是最后一次的数。

Más respuestas (0)

Categorías

Más información sobre 循环及条件语句 en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 17 de Nov. de 2022

Respondida:

el 17 de Nov. de 2022

Community Treasure Hunt

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

Start Hunting!