Make discontinuous data continuous

I have the following 2 arrays:
x = [0 450 1200 5000 9000 14000 20000]
y = [-23 6 -1 8 -8 1 -20]
I would like to interpolate on the x axis to get a total of 256 y values.
I've tried using y(index) but the problem there is that my x-axis data is discontinuous. Using the index function where Y is not already defined returns
Empty matrix: 1-by-0
Is there any way to connect each point to create a continuous distribution so I can use the index function?

Réponses (1)

Stephen23
Stephen23 le 20 Juin 2016
Modifié(e) : Stephen23 le 20 Juin 2016
>> xi = [0,450,1200,5000,9000,14000,20000];
>> yi = [-23,6,-1,8,-8,1,-20];
>> xo = linspace(xi(1),xi(end),256);
>> yo = interp1(xi,yi,xo);
>> yo(:)
ans =
-23.000000
-17.945534
-12.891068
-7.836601
-2.782135
2.272331
5.807843
5.075817
4.343791
3.611765
2.879739
... lots more here
-16.156863
-16.431373
-16.705882
-16.980392
-17.254902
-17.529412
-17.803922
-18.078431
-18.352941
-18.627451
-18.901961
-19.176471
-19.450980
-19.725490
-20.000000

Catégories

En savoir plus sur Interpolation dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by