# How to interpolate 3-D data from a .mat file?

조회 수: 2(최근 30일)
spider_plantt 2020년 8월 4일
답변: Raunak Gupta 2020년 8월 12일
I have a 256x256x256 struct in a .mat file that I'm trying to interpolate using meshgrid and interp3. What I'm trying to do is slice the 3-D image so that it re-interpolates onto a given grid. My code is below and since I'm very new to this I'm essentially rehashing the interp3 example code. I keep getting an error right now on line 2 [X,Y,Z,V]=load('gm.mat'), reading "Insufficient number of outputs from right hand side of equal sign to satisfy assignment".
[X,Y,Z,V]=sphere;
[Xq,Yq,Zq]=meshgrid(29:9:141,29:9:141,29:9:141);
Vq=interp3(X,Y,Z,V,Xq,Yq,Zq);
figure
slice(Xq,Yq,Zq,V,120,85,120);
##### 댓글 수: 2표시 이전 댓글 수: 1숨기기 이전 댓글 수: 1
spider_plantt 2020년 8월 4일
Can you clarify this error? It keeps cropping up.
Insufficient number of outputs from right hand side of equal sign to satisfy
assignment.

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

### 답변(1개)

Raunak Gupta 2020년 8월 12일
Hi,
From the question I understand you have the V data that is stored in the struct file as this is a 3D Image so only values will be stored of a particular (x,y,z) pixel. I think you need to know what the resolution of image is, like what is the spacing between adjacent pixel in each dimension. In that way you can construct the coordinates matrices X, Y, Z with that spacing using meshgrid.
If you see the example mentioned in the interp3 , the [X, Y, Z, V] = flow (10) return coordinate space in X, Y, Z and volume data in Z. All the matrices have same size.
So, you can probably create X,Y,Z as you created the Xq,Yq,Zq but with the actual spacing in the image dimesion between pixels. If you don’t know the spacing, then second syntax of interp3 mentioned here can also help.
Hope this clarifies!

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

### 범주

Find more on Interpolation in Help Center and File Exchange

R2018b

### Community Treasure Hunt

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

Start Hunting!