MATLAB: How to plots a data file by just using 10 points from each decade

plotnpointsfromeachdecade

For example, a data file has 2 column, in column 1 we have [1:1:10000] and in y-axis some experimental value. I would like to get a 'log-log' plots with only 10 points from each decade, like 1, 2,… 10, 20, …., 100, 200, …., 1000, 2000, ….. 10000 and the corresponding y values. This way instead of plotting 10000 points I will only plot 40 points and we will have exactly similar looking curve in log-log plot.

Best Answer

This should work to create your vector of indices:
idx = bsxfun(@times, [1:10]', logspace(0,3,4));
idx = unique(fix(idx(:)));
idx =
1
2
3
4
5
6
7
8
9
10
20
30
40
50
60
70
80
90
100
200
300
400
500
600
700
800
900
1000
2000
3000
4000
5000
6000
7000
8000
9000
10000
You could do this in one line, but there is no advantage to that, and it makes the code more difficult to read.
Related Question