How can I smooth 'trisurf' surface-plot?
15 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
How can I smooth the surface generated by 'trisurf' command?
% initially, x, y, z are coordinates of scattered data
x = scatteredValuesX;
y = scatteredValuesY;
z = scatteredValuesZ;
% to create a surface from the scattered data, a triangulation is used
% this method is suggested here: https://au.mathworks.com/matlabcentral/fileexchange/5105-making-surface-plots-from-scatter-data
tri = delaunay(x,y);
trisurf(tri, x, y, z);
The result is very noisy and I would like to smooth the surface, but I have not yet discovered the way of how to achieve this goal.
I have found a function 'smoothn' here which could potentially achieve what I need, but I am not sure if it is possible to adapt my data in order to feed this function properly.
Any input would be appreciated.

0 Commenti
Risposte (1)
Satwik
il 22 Apr 2025
Hi,
Here is workflow using which surface smoothening can be achieved for data plotted with 'trisurf', using 'smoothn':
1) Interpolation onto a grid: The scattered data are first interpolated onto a regular grid, which allows 'smoothn' to be used
% Define a grid
[xq, yq] = meshgrid(linspace(min(x),max(x),100), linspace(min(y),max(y),100));
% Interpolate scattered data onto the grid
zq = griddata(x, y, z, xq, yq, 'natural');
2. Smoothing the Surface:
zq_smooth = smoothn(zq); % 'smoothn' is available from the File Exchange
3. Plotting the Smoothed Surface: The smoothed surface is plotted with 'surf', not 'trisurf', since the data are now on a grid.
surf(xq, yq, zq_smooth, 'EdgeColor', 'none');
view(3); axis tight;
I hope this helps!
0 Commenti
Vedere anche
Categorie
Scopri di più su Surface and Mesh Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!