Interpolating a velocity field between time steps

조회 수: 10 (최근 30일)
Timotej Turk Dermastia
Timotej Turk Dermastia 2016년 2월 29일
댓글: Timotej Turk Dermastia 2016년 3월 1일
Hi! I am a relatively new user of Matlab, working on a project of particle advection in a hydodynamic environment. In order to simulate the advection I have to interpolate current velocities between time steps. I have a field of mean current velocities for each day. I want to split the day into 4 hour intervals, hence I would need to interpolate the velocities at 5 extra time steps. My velocity matrix is named MER.u (92x100x15), where the third dimension represents each day (15 in total). When trying to interpolate I am returned with an error ("The grid vectors do not define a grid of points that match the given values.").
I am struggling to construct a sentence where I would tell Matlab to treat MER.u(:,:,it), to be the corresponding value of MER.mt(1). I am aware that a date giving a field of velocities is not exactly a function but I was assuming linear 1D interpolation is the correct method for this (of course I could and likely am wrong). Can you please help with this, it should be fairly easy.
The code I am using is given bellow.
%MER.mt is a vector of 15 dates in datenum format
%MER:u is a grid 92x100x15 of velocities for 15 days
tn= [MER.mt(1):1/6:MER.mt(end)] ;
interp1(MER.mt, MER.u, tn);
  댓글 수: 2
KSSV
KSSV 2016년 3월 1일
You have a grid of 92X100. There is spatial variation as well as temporal variation. How you can use interp1? Give more information about the problem and data you have.
Timotej Turk Dermastia
Timotej Turk Dermastia 2016년 3월 1일
편집: Timotej Turk Dermastia 2016년 3월 1일
Yes I'm aware of this and as I said I don't know whether this is the right approach however My x in interp1(x,v,xq) is a 15x1 vector of times and my xq is a 85x1 vector of new times. My disiried output would be a grid of velocities 92x100x85 where 5 new fields would be calculated between the current time steps.

댓글을 달려면 로그인하십시오.

채택된 답변

KSSV
KSSV 2016년 3월 1일
u = rand(92,100,15) ; % random xcomponent of veclocity
v = rand(92,100,15) ; % random ycomponent of velocity
t = linspace(1,150,15) ; % time steps
ti = [5,20,70] ; % time where velocities are to be interpolated
% Initialize interpolated components
ui = zeros(92,100,length(ti)) ;
vi = zeros(92,100,length(ti)) ;
for i = 1:92
for j = 1:100
% u comp interpolation
uij = squeeze(u(i,j,:)) ;
ui(i,j,:) = interp1(t,uij,ti) ;
% v comp interpolation
vij = squeeze(v(i,j,:)) ;
vi(i,j,:) = interp1(t,uij,ti) ;
end
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by