Matlab Non-Integration Index Indexing

So I have a vector:

k = 1:100;

And I want to take from it 19 elements that are approximately equally distributed. So I write this:

m = k(1:(99/18):end);

This works fine except for a tiny problem:

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

Now I understand why this is happening, but I would like to get rid of this warning. Is there a “right” way to do this without warning?

+3
source share
1 answer

Try the following:

floor(linspace(1,100,19))
+8
source

Source: https://habr.com/ru/post/1746794/


All Articles