interpolating in 3 dimension for each cell position

조회 수: 1 (최근 30일)
Markus
Markus 2011년 11월 15일
hei,
i have a 3d matrix, where each layer into the 3rd dimension is a new measurement. i would like to interpolate invalid values (nans) along the 3rd dimension. one way i figured this out was doing it this way:
dd=squeeze(distProfile(2, 13, :));
dd_x=find(~isnan(dd));
dd_y=dd(~isnan(dd));
yi=interp1(dd_x,dd_y,1:length(dd));
distProfile(2, 13, :)=yi;
this works for one cell, however i have a couple of matrices 104x13x500. therefore i dont wanna have two loops going through every cell.
  댓글 수: 1
Image Analyst
Image Analyst 2011년 11월 15일
I'm not sure how you're defining "cell." To you, what does that mean? Is it like MATLAB defines cell (like a bucket or container into which you can thrown any type of variable) or do you mean it's the connected region of nan voxels, or do you mean "element" and are using cell like Excel defines cell?

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

답변 (1개)

Sean de Wolski
Sean de Wolski 2011년 11월 15일
It looks as though John's inpaint_nans3 has been removed from the FEX. It's what I would've recommended to start with. Perhaps look at Damien Garcia's
  댓글 수: 2
Markus
Markus 2011년 11월 15일
thanks for your answer
however, this is not working .. :(
the point is, that i want to have the interpolation just in one dimension. e. g. as mean(A,dim). since each cell is a certain measured value over time. i can write a loop to go through each cell, but this might take a while, which i wanna avoid.
Sean de Wolski
Sean de Wolski 2011년 11월 15일
It sounds like that might be your best bet. You could look at interp1q for quick linear interpolation.

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

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by