Converting from griddata3 to TriScatteredInterp

조회 수: 3 (최근 30일)
Aman
Aman 2011년 11월 8일
Hi I need help converting a line in my code to TriscatteredInterp.
This is the original line:
ReconstructedUS(:,:,bg:en) = griddata3(TGridX, TGridY, TGridZ, US, RegularGridX, RegularGridY, RegularGridZ, 'linear');
I tried converting to TriscatterInterp using:
F = TriScatteredInterp(TGridX(:,:,:), TGridY(:,:,:), TGridZ(:,:,:), US(:,:,:), 'linear');
ReconstructedUS(:,:,bg:en) = F(RegularGridX, RegularGridY, RegularGridZ);
However I keep getting the error that the dimensions are in an invalid space.
Any help?

답변 (2개)

Walter Roberson
Walter Roberson 2011년 11월 8일
Notice in the documentation,
F = TriScatteredInterp(X, V) creates an interpolant that fits a surface of the form V = F(X) to the scattered data in (X, V). X is a matrix of size mpts-by-ndim, where mpts is the number of points and ndim is the dimension of the space where the points reside (ndim is 2 or 3). The column vector V defines the values at X, where the length of V equals mpts.
But your TGridX is three dimensional, which is not a two dimensional array of size mpts x 2 or mpts x 3
So:
F = TriScatteredInterp( [TGridX(:), TGridY(:), TGridZ(:)], US(:), 'linear');
  댓글 수: 4
Walter Roberson
Walter Roberson 2011년 11월 8일
I do not see any particular reason why you have bg and en in your ReconstructedUS array indices, but presumably it relates to the code you used to select the data.
I have no idea what the performance difference is between interp3 and TriscatteredInterp. My naive expectation would be that interp3 would be faster as it does not need to search to track which vertices are closest in order to do the interpolation.
When I saw your question I assumed it had to do with the question earlier today from someone whose data was not quite regular, but that turns out to be a different author: http://www.mathworks.com/matlabcentral/answers/19607-interp3-problem
Aman
Aman 2011년 11월 9일
Yes I am using bg/en to select a certain frame of sequences to reconstruct based on the raw ultrasound data. I just wanted to know if it was an acceptable line of code. Thanks for your help!

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


Aman
Aman 2011년 11월 9일
Three different tries, still no results. Stumped as to why this isn't functioning properly.
??? Error using ==> TriScatteredInterp The input points must be a double array.
Error in ==> US_Reconstruction_v2b at 172 F = TriScatteredInterp([TGridX(:), TGridY(:), TGridZ(:)], US(:), 'linear');
??? Error using ==> TriScatteredInterp Input data point values have invalid dimension.
Error in ==> US_Reconstruction_v2b at 172 F = TriScatteredInterp([TGridX(:,:), TGridY(:,:), TGridZ(:,:)], US(:,:), 'linear');
??? Error using ==> TriScatteredInterp Input data point values have invalid dimension.
Error in ==> US_Reconstruction_v2b at 172 F = TriScatteredInterp([TGridX(), TGridY(), TGridZ()], US(), 'linear');
Any insight would be deeply appreciated!
  댓글 수: 2
Walter Roberson
Walter Roberson 2011년 11월 9일
"a double array" means an array of datatype double precision. What data class are your TGrid* and US ?
Aman
Aman 2011년 11월 9일
TGrid* and US are both 510X2064X109 double

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

카테고리

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