poster
2019-12-10, 20:41
所以,我有一个向量:
k = 1:100; 我想从中取19个元素,它们之间的间距大致相等。所以我这样写:
m = k(1:(99/18):end); 这很好用,除了一个小问题:
Warning: Integer operands are required for colon operator when used as index m = 1 7 12 18 23 29 34 40 45 51 56 62 67 73 78 84 89 95 100 现在,我明白了为什么会这样,但我想摆脱该警告。有没有警告的“正确”方法吗?
回答:
尝试这个:
floor(linspace(1,100,19))
更多&回答... (https://stackoverflow.com/questions/2893596)
k = 1:100; 我想从中取19个元素,它们之间的间距大致相等。所以我这样写:
m = k(1:(99/18):end); 这很好用,除了一个小问题:
Warning: Integer operands are required for colon operator when used as index m = 1 7 12 18 23 29 34 40 45 51 56 62 67 73 78 84 89 95 100 现在,我明白了为什么会这样,但我想摆脱该警告。有没有警告的“正确”方法吗?
回答:
尝试这个:
floor(linspace(1,100,19))
更多&回答... (https://stackoverflow.com/questions/2893596)