MATLAB Answers

How can I create a cell that splits a sequence of numbers (1 : n) in equal parts?

조회 수: 21(최근 30일)
If I have a sequnce of numbers (1 : 40) I want to create a cell which splits that sequence into ({1 : 20} {21 : 40}) or of I want to go a step further ({1 : 10}{11 : 20}{21 : 30}{31 : 40}) and so on.

  댓글 수: 0

댓글을 달려면 로그인하십시오.

채택된 답변

Matt J
Matt J 6 Jan 2021
Using mat2tiles,
>> C=mat2tiles(1:40,[1,10]);
>> C{:}
ans =
1 2 3 4 5 6 7 8 9 10
ans =
11 12 13 14 15 16 17 18 19 20
ans =
21 22 23 24 25 26 27 28 29 30
ans =
31 32 33 34 35 36 37 38 39 40

추가 답변(0개)

Community Treasure Hunt

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

Start Hunting!

Translated by