Add Interpolated Vector to Matrix

2 Ansichten (letzte 30 Tage)
Gonzo Gonzo
Gonzo Gonzo am 7 Mai 2020
Kommentiert: Gonzo Gonzo am 7 Mai 2020
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

Akzeptierte Antwort

Matt J
Matt J am 7 Mai 2020
Bearbeitet: Matt J am 7 Mai 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

Weitere Antworten (0)

Kategorien

Mehr zu Interpolation finden Sie in Help Center und File Exchange

Produkte


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by