matlab noninteger step indexing
So, I have a vector:
k = 1:100;
And I want to take 19 elements from it, which are roughly equally-spaced. So I write this:
m = k(1:(99/18):end);
This works great, except for a tiny problem:
Warning: Integer operands are required for colon operator when used as index
m =
1 7 12开发者_如何学Python 18 23 29 34 40 45 51 56 62 67 73 78 84 89 95 100
Now, I understand why this comes up, but I'd like to get rid of that warning. Is there a "right" way to do this without a warning?
Try this:
floor(linspace(1,100,19))
精彩评论