In Matlab, I can use logspace(A,B,N) to generate a vector of length N, containing points between 10^A and 10^B evenly spaced along a logarithmic axis. However, because of the nature of the logarithm, these points usually end up at data points which make no sense in themselves, and I have to create a logspace with a very large number of points if I want to make sure that a certain data point is exactly represented in the vector.
Is there a way for me to specify certain data points that should be included in the vector?
For example, logspace(1,10,30, [25 50 75]) would generate a vector of lenght 30 with points distributed almost equally along a logarithmic axis, but making sure that all the points 25, 50 and 75 are included.
Perhaps you are doing some sort of plot and what you need is the reference points for those specific values. If that’s the case you can also handle the logspace vector separately to the special values, for example, by overlaying two plots.
Otherwise I like @reve_etrange’s idea of simply adding those specific points into your vector.
Update
In a case like this where the calculations for each element do not depend on (1) the order of elements or (2) the values of the other elements in the vector, there is no need to sort the input for the purpose of calculation – and especially if you want to treat the special values differently when plotting.
Instead, just tack on the special values at the end, and then split the output vector to get the special outputs.