Interpolating function to make two arrays synchronise
6 次查看(过去 30 天)
显示 更早的评论
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)';
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!