基于matlab/octave中的其他数字列表获取数字
当我在matlab/octave中输入(1:4:16)时 我得到的答案是1,5,9,13 有没有办法让我找到丢失的号码基于matlab/octave中的其他数字列表获取数字,matlab,octave,Matlab,Octave,当我在matlab/octave中输入(1:4:16)时 我得到的答案是1,5,9,13 有没有办法让我找到丢失的号码 so instead of getting 1,5,9,13 I get 2,3,4,6,7,8,10,11,12,14,15,16 您可以使用此功能: function num = getTheMissingNumbers( from, jump, to ) num = from:to; num = setdiff( num, from:jump:to ); 你可以调
so instead of getting 1,5,9,13
I get 2,3,4,6,7,8,10,11,12,14,15,16
您可以使用此功能:
function num = getTheMissingNumbers( from, jump, to )
num = from:to;
num = setdiff( num, from:jump:to );
你可以调用这个函数
>> getTheMissingNumbers( 1, 4, 16 )
要得到你想要的号码
如果进一步假设
getThemissingNumbers
的输入总是以1开头,那么使用
function num = getTheMissingNumbers( jump, to )
num = 1:to;
num(1:jump:to) = []; % remove the elements in ind
根据评论编辑。不幸的是,这不会一直到16岁(如果OP想要的话)。