Add Interpolated Vector to Matrix

5 views (last 30 days)
Hi,
I'm trying to interpolate velocity values over a range of heights and times to then save it into a matrix. I'm having trouble getting the data to save/interpolate properly.
When I used Ninterp(:,t) = interp2(ADCP.t,ADCP.Depth,ADCP.N,time_in,Z); I was able to get it to work for t=1:1:100, however I need it to work for different time steps then just 1.
ADCP.N - North velocity values as a function of depth and time (82x1000)
ADCP.t - datenum time vector from the sensor
ADCP.Depth - depth of water column
time_in - an arbitrary time vector (may not be an integer) to interpolate through
Z - an arbitrary range of heights to interpolate through
Z = [150:-1:1];
Nq = zeros(length(ADCP.t));
for t=1:.25:100
time_in = tStart+datenum([0,0,0,0,0,t]);
Ninterp = interp2(ADCP.t,ADCP.Depth,ADCP.N,time_in,Z);
Nq = Ninterp(t)
end

Accepted Answer

Matt J
Matt J on 7 May 2020
Edited: Matt J on 7 May 2020
Z = [150:-1:1];
Nq = zeros(length(ADCP.t));
t=1:0.25:100;
clear Ninterp
for i=length(t):-1:1
time_in = tStart+datenum([0,0,0,0,0,t(i)]);
Ninterp(:,i) = interp2(ADCP.t,ADCP.Depth,ADCP.N,time_in,Z);
end

More Answers (0)

Categories

Find more on Interpolation in Help Center and File Exchange

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!