Prev: vsim / Modelsim
Next: MPM in Matlab program
From: Aditya Gupta on 4 Dec 2009 20:04 Hello, I've two layers at (x,y, z = 1) and (x,y,z = 2) and I'm trying to interpolate to have two additional layers in between these two layers. The two additional layers should have values which is an interpolation (spline or cubic) of the original two layers. I'm working with interp3 but getting the error below: %slice is a 613 X 561 X 2 of type double m1 = size(slice,1); n1 = size(slice,2); X1 = 1:m1; Y1 = 1:n1; Z1 = 1:2; V = slice(:,:,1:2); XI = 1:m1; YI = 1:n1; ZI = [1.3,1.7]; VI = interp3(X1,Y1,Z1,V,XI,YI,ZI); The error I'm getting is: Error using ==> interp3 at 129 The lengths of X,Y and Z must match the size of V. Error in ==> hrt3dconstinter1 at 266 VI = interp3(X1,Y1,Z1,V,XI,YI,ZI); >>size(V) ans = 613 561 2 I don't understand, the size(V) is supposed to be [m1,n1,2] according to matlab doc. Can you please help me what mistake am I making? Thank you. Gupta
From: Bruno Luong on 5 Dec 2009 07:43 Not check on Matlab, but I'm pretty sure the inputs XI, YI, ZI should have the same size, because they are usually scattered data. It is not the case in your code Bruno
From: Bruno Luong on 5 Dec 2009 08:20 BTW, INTERP3 is overkill, INTERP1 is enough Bruno
From: Aditya Gupta on 5 Dec 2009 15:10 Thanks for the reply. The MATLAB doc says X=1:N, Y=1:M, Z=1:P where [M,N,P]=size(V). Regarding the XI, YI and ZI MATLAB doc says: XI,YI, ZI must be arrays of the same size, or vectors. Vector arguments that are not the same size, and have mixed orientations (i.e. with both row and column vectors) are passed through meshgrid to create the Y1, Y2, Y3 arrays. I'm not clear on the last statement. Anyway can you suggest a method I can use to obtain the intensities at the two intermediate layers (as mentioned in the initial post). Is there any other function I could use? Thanks. Gupt "Bruno Luong" <b.luong(a)fogale.findmycountry> wrote in message <hfdmmj$ql5$1(a)fred.mathworks.com>... > BTW, INTERP3 is overkill, INTERP1 is enough > > Bruno
From: Bruno Luong on 5 Dec 2009 15:34
"Aditya Gupta" <adityargupta(a)gmail.com> wrote in message <hfeena$fhb$1(a)fred.mathworks.com>... > Thanks for the reply. The MATLAB doc says > X=1:N, Y=1:M, Z=1:P where [M,N,P]=size(V). > Regarding the XI, YI and ZI MATLAB doc says: > XI,YI, ZI must be arrays of the same size, or vectors. Vector arguments that are not the same size, and have mixed orientations (i.e. with both row and column vectors) are passed through meshgrid to create the Y1, Y2, Y3 arrays. > Mix orientation: an example XI = 1:3 YI = (4:5).' ZI = 6:7 There are two rows vectors and one column vector. In your case they are all rows. All rows/columns are interpreted as a long list of scattered data, so they must have the same length. Just flip one then, or generate same size array with ndgrid. Bruno |