Matlab 按一定数量分割数字
我试图将数字按给定值(4000)拆分,并将数字放入一个数组中 例如: 给出的最大值为:8202 因此,split_数组应该按4000进行拆分,除非它到达末尾并且小于4000 在这种情况下,它就结束了Matlab 按一定数量分割数字,matlab,if-statement,for-loop,while-loop,octave,Matlab,If Statement,For Loop,While Loop,Octave,我试图将数字按给定值(4000)拆分,并将数字放入一个数组中 例如: 给出的最大值为:8202 因此,split_数组应该按4000进行拆分,除非它到达末尾并且小于4000 在这种情况下,它就结束了 start_pos, end_pos 0,4000 4001,8001 8002,8202 so the first row in the array would be [0 4000] second row would be [4001 8001] third row would be [80
start_pos, end_pos
0,4000
4001,8001
8002,8202
so the first row in the array would be
[0 4000]
second row would be
[4001 8001]
third row would be
[8002 8202]
请注意,最大值可以从(8202)更改为任何其他数字,如(16034),但不能是小数
我如何使用matlab/octave来做这件事呢?这应该会产生你想要的结果
n = 8202;
a = [0:4001:n; [4000:4001:n-1 n]]'
返回
a =
0 4000
4001 8001
8002 8202
这应该会产生你想要的
n = 8202;
a = [0:4001:n; [4000:4001:n-1 n]]'
返回
a =
0 4000
4001 8001
8002 8202
在您的示例中,第一行是
[0 4000]
还是0:4000
?您是否只包括开始和结束或两者之间的所有内容?@horchler在您的示例中,第一行是[0 4000],第一行是[0 4000]
还是0:4000
?你只是包括开始和结束,还是包括开始和结束之间的所有内容?@horchler第一行是[0 4000]