Interpolating function to make two arrays synchronise

14 visualizzazioni (ultimi 30 giorni)
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)';

Risposta accettata

KSSV
KSSV il 5 Nov 2020
Modificato: KSSV il 5 Nov 2020
x = Init_Density(1:end);
y = Depth;
xi = linspace(min(x),max(x),600);
yi = interp1(x,y,xi);

Più risposte (0)

Categorie

Scopri di più su Line Plots in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by