From: Christian Reiss on
HI all-

I have a three-D array 120*100*100, I wish to interpolate the data along the third dimension so that the end result is a matrix 120*100*199. The third dimension is equally spaced. The ouput array would have interpolated values at points between each of the rows and columns and the original data should not be touched (a simple average of nearest neighbors would be fine).

interp3 works across all elements as aa=interp3(X,3), and doesnt work.

It would be better than what I am thinking (although i am brain dead at this moment)
something like...
for i= 1: length(U-1)

Uaaa=(U(:,:,i)+U(:,:,i+1))/2; % not actually interp.. just element average

U_new=cat(3, U(:,:,i), Uaaa, U(:,:,i+1));...
end

any help would be appreciated

thanks
chris
From: Bruno Luong on
One way:

% Data
U=rand(2,3,10)

Unew = permute(U,[3 1 2]);
Unew = interp1(1:p,Unew,1:0.5:p);
Unew = ipermute(Unew,[3 1 2]);

% Bruno
From: Bruno Luong on
Sorry I miss a line of code:

> % Data
> U=rand(2,3,10)
>

p = size(U,3)

> Unew = permute(U,[3 1 2]);
> Unew = interp1(1:p,Unew,1:0.5:p);
> Unew = ipermute(Unew,[3 1 2]);
>

% Bruno
From: Christian Reiss on
thanks bruno-

This gives me some new thoughts, and at least a tempoary solution!

cheers
chris

"Christian Reiss" <christian.reiss(a)noaa.gov> wrote in message <hvgrs8$45s$1(a)fred.mathworks.com>...
> HI all-
>
> I have a three-D array 120*100*100, I wish to interpolate the data along the third dimension so that the end result is a matrix 120*100*199. The third dimension is equally spaced. The ouput array would have interpolated values at points between each of the rows and columns and the original data should not be touched (a simple average of nearest neighbors would be fine).
>
> interp3 works across all elements as aa=interp3(X,3), and doesnt work.
>
> It would be better than what I am thinking (although i am brain dead at this moment)
> something like...
> for i= 1: length(U-1)
>
> Uaaa=(U(:,:,i)+U(:,:,i+1))/2; % not actually interp.. just element average
>
> U_new=cat(3, U(:,:,i), Uaaa, U(:,:,i+1));...
> end
>
> any help would be appreciated
>
> thanks
> chris
From: Sean on
"Christian Reiss" <christian.reiss(a)noaa.gov> wrote in message <hvgnbc$ohq$1(a)fred.mathworks.com>...
> HI all-
>
> I have a three-D array 120*100*100, I wish to interpolate the data along the third dimension so that the end result is a matrix 120*100*199. The third dimension is equally spaced. The ouput array would have interpolated values at points between each of the rows and columns and the original data should not be touched (a simple average of nearest neighbors would be fine).
>
> interp3 works across all elements as aa=interp3(X,3), and doesnt work.
>
> It would be better than what I am thinking (although i am brain dead at this moment)
> something like...
> for i= 1: length(U-1)
>
> Uaaa=(U(:,:,i)+U(:,:,i+1))/2; % not actually interp.. just element average
>
> U_new=cat(3, U(:,:,i), Uaaa, U(:,:,i+1));...
> end
>
> any help would be appreciated
>
> thanks
> chris

%A hint; if you're still looking.
A = cat(3,ones(3),2*ones(3),3*ones(3));
[xold yold zold] = ndgrid(1:3,1:3,1:2:5);
[xnew ynew znew] = ndgrid(1:3,1:3,1:5);

griddata3(xold,yold,zold,A,xnew,ynew,znew)