Regarding Interpolation( vertical)
2 views (last 30 days)
Show older comments
I have two data sets in which one is 4D data sets and another one is 2D.
1) first data: 120( longitude) x 90(latitude) x 34 (vertical level) x 8 (Time) 2) second data: 15( vertical level) x 469( number of observations)
I would like to interpolate 34 vertical levels to 15 vertical levels. so somebody knows how to fix this problem?
0 Comments
Answers (2)
Sean de Wolski
on 18 Jul 2011
A = rand(5,5,34,5);
[ii jj kknew LL] = ndgrid(1:5,1:5,linspace(1,34,15),1:5);
C = interpn(A,ii,jj,kknew,LL);
You could just use interpn directly, thought this will use information from other dimensions.
4 Comments
Andrei Bobrov
on 18 Jul 2011
In = DataInput; % Array 4D
[a b oldc d] = size(In);
newc = 15;
Out = zeros([a b newc d]);
for j4 = 1:d
d1 = reshape(permute(In(:,:,:,j4),[3 2 1]),oldc,[]);
Out(:,:,:,j4) = permute(reshape(cell2mat(arrayfun(@(i1)interp1((1:oldc)',d1(:,i1),linspace(1,oldc,newc)'),1:a*b,'un',0)),newc,b,a),[3 2 1]);
end
0 Comments
See Also
Categories
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!