interp3 problem: the value of the last sampling coordinate is not match.

1 view (last 30 days)
Dear Matlab users
I am currently working on a project that involves using MATLAB's interp3 function to interpolate a profile between two points in a 3D dataset. These points are p1 (labeled as starting_point: x1, y1, z1) and p2 (labeled as mid_point: ,x2, y2, z2). The shape of my 3D dataset, rtdose_imgs, is (512, 512, 371), and it consists of double type values.
I have encountered an issue where the interpolated value at p2 does not match the expected value.
The known value at p2 in rtdose_imgs (coordinates x2, y2, z2) is 42.2477. However, the value obtained at the end of the interpolated profile using interp3 is different from this.
I am seeking help to resolve this discrepancy. Any insights or suggestions on how to correctly interpolate the profile between p1 and p2 would be greatly appreciated.
Thank you in advance for your assistance.
numPoints = 183; % You can change this based on the resolution you need
% Generating linearly spaced points between p1 and p2
xq = linspace(st_point_pad(1), mid_point(1), round(numPoints/2));
yq = linspace(st_point_pad(2), mid_point(2), round(numPoints/2));
zq = linspace(st_point_pad(3), mid_point(3), round(numPoints/2));
sz_rtdose_imgs = size(rtdose_imgs);
[X,Y,Z] = meshgrid(1:sz_rtdose_imgs(1),1:sz_rtdose_imgs(2),1:sz_rtdose_imgs(3));
% [Xq,Yq,Zq] = meshgrid((st_point_pad(1):1:mid_point(1)),(st_point_pad(2):1:mid_point(2)),st_point_pad(3):1:mid_point(3))
% Interpolate the values from the 3D matrix
% doseProfile_init = interp3(rtdose_imgs, x, y, z);
doseProfile_init = squeeze(interp3(X,Y,Z, rtdose_imgs, xq,yq,zq))
  2 Comments
Angelo Yeo
Angelo Yeo on 9 Jan 2024
In order to find the precise cause and solution for the issue you are currently experiencing, I believe that the following additional information would be necessary. If you could provide the following information, it would enable contributors, including myself, to assist you more effectively:
1) Example files and data files that can reproduce the issue
2) Exact steps to reproduce the same problem using the files you provided
Wonjoong
Wonjoong on 9 Jan 2024
Thanks to your response.
According to your adivce, I attached the file realated that situation: 1) function that i wrote, 2) a set of variables
In the case of the set of vatiables, the volume is large, I attached a link you can download it.
In the case of the function that i worte, attahced in this post. (focused to line 58~71)
PS) I don't understand why the value of last postition is not match, after 3D interpolation.
Becuase the last position (=3D coordinates) is explicitly provided and the value of the last position is alreay exist.
Best regards
Wonjoong Cheon

Sign in to comment.

Answers (1)

Stephen23
Stephen23 on 9 Jan 2024
Edited: Stephen23 on 9 Jan 2024
  1 Comment
Wonjoong
Wonjoong on 12 Jan 2024
Edited: Wonjoong on 12 Jan 2024
I changed 1) meshgird -> ndgrid , 2)interp3 -> interpn. but the new code was not working well. (code is working, but precise interpolation is not working well)
I finally divided the desired section based on the coordinates for which I wanted a very clear interpolation value, performed interpolation on each, and then concatenated them.
t.t

Sign in to comment.

Tags

Products

Community Treasure Hunt

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

Start Hunting!