how to use interp1() function
36 vues (au cours des 30 derniers jours)
I have tried to use interpt(1) function as i have time and pressure data.
the pressure data is highly scattered it look like that
firstly,I have used function : p0q=interp1(p0,tq) as show belows
but the poq (interpolated result is empty) as shown in the figure
when i change it to
the interploted data are incorrect
is there something wrong in my code?or i am using the function incorrectly?
Stephen23 le 12 Fév 2020
Modifié(e) : Stephen23 le 12 Fév 2020
The problem is that you are using the default x values, which for a vector input are defined as
These default points only make sense if you are also requesting interpolation for x>=1 and x<=numel(v), but look at the x points you are requesting interpolation at: judging by your screenshot they are somewhere between 0.06162 and 0.06067. The points you are requesting lie nowhere close to the the input x values (for which you used the default values 1:numel(v), and which iare thus totally unsuitable for your task).
The solution is simple: you need to provide the input x values, i.e.:
p0q = interp1(t1, p0, tq);