Info

This question is closed. Reopen it to edit or answer.

How to get 1807 point data array to 1806 data array?

1 view (last 30 days)
SL
SL on 24 Oct 2016
Closed: MATLAB Answer Bot on 20 Aug 2021
I thought the process would go with interpolation like the following but not
u = interp1(u, size(u) - 1);
which gives me `NaN [integer]`, so wrong.
I do not want to lose the accuracy of the results but I need to compare the vector with its original vector which has one point less.
MATLAB: 2016b

Answers (2)

Guillaume
Guillaume on 24 Oct 2016
As Marc says, you need a vector for the query points but his solution for generated that vector does not make much sense.
A good way of generating one less query point than the original is to use linspace:
uq = interp1(u, linspace(1, numel(u), numel(u)-1))
That's assuming that the original u correspond to x = 1:numel(u).
  3 Comments
Guillaume
Guillaume on 25 Oct 2016
Yes, exactly what Marc said. There's nothing complicated about the code and certainly no non-linear regression. Just plain linear interpolation.

Marc Jakobi
Marc Jakobi on 24 Oct 2016
Edited: Marc Jakobi on 24 Oct 2016
The second input must be a vector, not the size of the output. So if you want to interpolate between the points, use something like
uq = interp1(u, (1.5:length(u) - 0.5)); %assuming u is a vector
  2 Comments
Marc Jakobi
Marc Jakobi on 24 Oct 2016
woops, wasn't paying proper attention there.
it should be
1.5:length(u)-0.5
(assuming u is a vector) Thanks for pointing it out.

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!