i'm using matlab read large (netcdf) data set information magnetic field. data set three-dimensional array of 318x562x554 , can retrieve have 3 one-dimensional array (318x1, 562x1 , 554x1) each axis values of coordinates. know magnetic field values on points not fit on data set grid. these points in case trajectory coordinates of spacecraft placed in two-dimensional array (3xn,n depends on how many coordinates have).
x = ncread(file,'x_axis'); y = ncread(file,'y_axis'); z = ncread(file,'z_axis'); bx = ncread(file,'bx'); [x2,y2,z2] = meshgrid(y,x,z); length = numel(interval_et_5000); bx_intp = zeros(1,length); = 1:length [xi,yi,zi] = meshgrid(position_mex_mars_5000(1,i),... position_mex_mars_5000(2,i),... position_mex_mars_5000(3,i)); f = interp3(x2,y2,z2,bx,xi,yi,zi); bx_intp(i) = f; end i have tried many things didn't work. 'works' not correct because values in bx_intp way high. because of doing coordinates 1 @ time in loop makes slow, normal run 3500 coordinates.
so basicly looking reverse scatteredinterpolant. function accepts random data points , interpolate values on meshgrid. have regular grid , want interpolation on random points.
thanks tip ashish uthama! got working code below. other people same problem. need ndgrid instead of meshgrid griddedinterpolant , coordinates need monotonic increasing.
x = ncread(file,'x_axis'); y = ncread(file,'y_axis'); z = ncread(file,'z_axis'); bx = ncread(file,'bx'); [x2,y2,z2] = ndgrid(x,y,z); f = griddedinterpolant(x2,y2,z2,bx,'linear','none'); bx_intp = f(position_mex_mars_5000(1,i),... position_mex_mars_5000(2,i),... position_mex_mars_5000(3,i));
Comments
Post a Comment