Error with 3D interpolation: Interpolation requires at least two sample points for each grid dimension
53 ビュー (過去 30 日間)
古いコメントを表示
I am trying to interpolate a 3D grid (sample file is attached) file, that has several 1D depth profiles (image attached). My goal is to generate an interpolated 3D volume from the grid. My code is as follows:
VsGrid = csvread('3d_Vs_utm_samplefile.csv');
X = VsGrid(:,1); % UTM X
Y = VsGrid(:,2); % UTM Y
Z = VsGrid(:,3); % Depth
V = VsGrid(:,4); % Shear wave velocity values
figure(1) % Display the imported data
scatter3(VsGrid(:,1), VsGrid(:,2), VsGrid(:,3), [], VsGrid(:,4), 'Marker', '.');
[Xq,Yq,Zq] = meshgrid(547151:100:550828,5402976:100:5405454,-2000:50:0); % Create a 3D mesh
Vq = interp3(X,Y,Z,V,Xq,Yq,Zq); % Interpolate the grid file
When I am running the above code, I am getting an error "Interpolation requires at least two sample points for each grid dimension". I have tried using different grid intervals for Xq, Yq and Zq, but nothing seems to work. Can someone please guide me through this?
Thank you.
0 件のコメント
採用された回答
Torsten
2023 年 10 月 31 日
編集済み: Torsten
2023 年 11 月 1 日
VsGrid = csvread('3d_Vs_utm_samplefile.csv');
X = VsGrid(:,1); % UTM X
Y = VsGrid(:,2); % UTM Y
Z = VsGrid(:,3); % Depth
V = VsGrid(:,4); % Shear wave velocity values
F = scatteredInterpolant(X,Y,Z,V,'linear','nearest')
figure(1) % Display the imported data
scatter3(VsGrid(:,1), VsGrid(:,2), VsGrid(:,3), [], VsGrid(:,4), 'Marker', '.')
colorbar
Xmin = min(X)
Xmax = max(X)
Ymin = min(Y)
Ymax = max(Y)
Zmin = min(Z)
Zmax = max(Z)
[Xq,Yq,Zq] = meshgrid(linspace(Xmin,Xmax,50),linspace(Ymin,Ymax,50),linspace(Zmin,Zmax,50)); % Create a 3D mesh
Vq = F(Xq,Yq,Zq);
figure(2) % Display the interpolated/extrapolated data
scatter3(Xq(:), Yq(:), Zq(:), [], Vq(:), 'Marker', '.')
colorbar
3 件のコメント
Torsten
2023 年 11 月 1 日
I don't know what you mean by
"scatteredInterpolant" does interpolates, but it gives interpolated 3D scattered point file. There are no values between those points.
"scatteredInterpolant" gives interpolated values at the points that you prescribe.
Above, you prescribe that you want to have values for V on the brick grid
linspace(Xmin,Xmax,50) x linspace(Ymin,Ymax,50) x linspace(Zmin,Zmax,50)
and F(Xq,Yq,Zq) returns these values.
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!