Interpolating function to make two arrays synchronise

6 visualizaciones (últimos 30 días)
Tom Edwards
Tom Edwards el 5 de Nov. de 2020
Comentada: Tom Edwards el 8 de Nov. de 2020
I have an array of 101 values between 0 and 600 called Depth and another called Init_Density with 101 values between 350 - 900. Each data point corresponds to a layer so they can be plotted together and match up, some layers are thicker or thinner than others which is why we have this non regular synchronising between density and depth. I want to interpolate both arrays so I have 600 values in each that can still match up, I have tried messing around with the interp1 function but it keeps giving me NaN values and I'm not sure what I'm doing wrong, nor how to correct it.
Heres my code, I've written the variables up just as you'd see them in the workspace, I don't want to type out 101 numbers but the Depth variable
Init_Density (101 x 1 double)
Depth (101 x 1 double)
x = Init_Density(1:end);
y = Depth;
ran = 1:1:600;
xi = interp1(x,Depth,ran)';

Respuesta aceptada

KSSV
KSSV el 5 de Nov. de 2020
Editada: KSSV el 5 de Nov. de 2020
x = Init_Density(1:end);
y = Depth;
xi = linspace(min(x),max(x),600);
yi = interp1(x,y,xi);

Más respuestas (0)

Categorías

Más información sobre Interpolation en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by