interpolation of a sinusoidal tunnel data
5 次查看(过去 30 天)
显示 更早的评论
hallo eveyone, i have fluent data of a flow instive a wavy tunnel as present here. I export the data as ACII file and i want to crate matrixs so i can work on the data preaty easely. the problem is that all the scatterd interpolation mathods do not work smothly on a wavy wall, wich asagnifetly decline. i need bater mathod to work with that interpolat on the wall in between those data points and not in the normal x y deraction? any segestions ??? may data is simpal scatterd data of x,y,and u
3 个评论
回答(2 个)
Mathieu NOE
2024-6-11
hello again
so I looked a bit some of your data , and my first question would be , why not first plot your (scattered) data with quiver or a colored quiver function, before doing some meshgrid & interpolation
here I used this Fex submission : Quiver - magnitude-dependent color in 2D and 3D - File Exchange - MATLAB Central (mathworks.com)
and you can see that there are no artifacts in the plot rendering.
then , if you really want to do meshgrid & interpolation, I noticed than 500 or 2500 points of interpolation, nor the method used had a great effect on reducing (to zero) the little "steps" close to the boundary; the only fix I could suggest here is to add a bit of 2D smoothing
here I used this Fex submission, but there are other alternatives if you have your own prefered function for this task : smooth2a - File Exchange - MATLAB Central (mathworks.com)
Quiver plot :
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1713401/image.png)
Filled contour plot - before smoothing :
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1713406/image.png)
Filled contour plot - after smoothing :
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1713411/image.png)
load('matlab.mat')
% Name Size Bytes Class Attributes
%
% section_P 37502x1 300016 double
% section_T 37502x1 300016 double
% section_Tw 37502x1 300016 double
% section_u 37502x1 300016 double
% section_v 37502x1 300016 double
% section_x 37502x1 300016 double
% section_y 37502x1 300016 double
figure(1) % quiver plot (with colors)
quiverC2D(section_x,section_y,section_u,section_v,1);
% Fex : https://fr.mathworks.com/matlabcentral/fileexchange/58527-quiver-magnitude-dependent-color-in-2d-and-3d?s_tid=ta_fx_results
colorbar('vert');
N = 1000; % 2500
interp_X = linspace(min(section_x), max(section_x), N);
interp_Y = linspace(min(section_y), max(section_y),round(N*0.694444444)); % "round" added
% Construct meshgrid
[interp_x, interp_y] = meshgrid(interp_X, interp_Y);
% velocity field
velo = sqrt(section_u.^2+section_v.^2).*sign(section_u);
% NB sign of section_u is used to show forward or backward oriented flow
% Interpolation using scatteredInterpolant on normalized coordinates
method = 'natural';
F_velo = scatteredInterpolant(section_x, section_y, velo, method, 'none');
Z = F_velo(interp_x, interp_y);
figure(2) % contourf plot
grid on
[hq,hqlbl] = contourf(interp_X,interp_Y,Z);
clabel(hq,hqlbl)
colorbar('vert');
% contourf plot with smoothing
ZS = smooth2a(Z,8,8);
figure(3) % contourf plot
grid on
[hq,hqlbl] = contourf(interp_X,interp_Y,ZS);
clabel(hq,hqlbl)
colorbar('vert');
3 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!