Surf plot Mesh Plot
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Respected Sir,
I have three parameters P, Q and R all having 216 values and none is dependent on other (all are obtained independently)
Kindly let me know if I can plot surf/grid plot with these values. If not, any other plot except using trisurf command.
Excel file is attached herewith.
Thanks in advance.
Respuestas (1)
Abhishek
el 11 de Jun. de 2025
It is my understanding that you want to generate a 3D surface plot from independently obtained variables ‘P’, ‘Q’, and ‘Lx’, where the data is not arranged on a structured grid in MATLAB.
In such cases, MATLAB’s ‘surf’ function cannot be used directly on raw data. This is because ‘surf’ expects data to be arranged on a uniform grid, whereas your data points are scattered. However, by interpolating the scattered values onto a regular grid, it is possible to visualize the surface using ‘surf’, without resorting to ‘trisurf’. To handle this, I used MATLAB’s ‘scatteredInterpolant’ function, specifically designed to interpolate scattered data onto a grid.
Here’s a simple step-by-step guide to do this:
- Load and extract data: Extract the three columns and assign them to three variables corresponding to ‘P’,’Q’, and ‘Lx’.
- Construct a surface interpolation model: Since the data points are scattered and not arranged on a grid, ‘scatteredInterpolant’ is used to construct a surface interpolation model:
F = scatteredInterpolant(P, Q, Lx, 'natural', 'none');
- Generate a regular grid in the domain of P and Q: This step defines the structure on which to evaluate the interpolated values:
p_lin = linspace(min(P), max(P), 50);
q_lin = linspace(min(Q), max(Q), 50);
[PP, QQ] = meshgrid(p_lin, q_lin);
- Evaluate interpolated values on the grid: Use the interpolation function to compute ‘Lx’ over the defined grid:
RR = F(PP, QQ);
- Visualisation: The interpolated data is now in a format compatible with ‘surf’, allowing the surface to be plotted:
surf(PP, QQ, RR)
xlabel('P (Radian)')
ylabel('Q (Radian)')
zlabel('Lx (mm)')
title('Interpolated Surface from Scattered Data')
shading inte
I tried it on MATLAB R2024b, here is the output:

As you can see above, the mentioned approach successfully generated the desired surface plot.
For further reference on ‘scatterInterpolant’ and ‘surf’ methods, refer to the official MATLAB documentation:
- ‘scatterInterpolant’: https://www.mathworks.com/help/releases/R2024b/matlab/ref/scatteredinterpolant.html
- ‘surf’: https://www.mathworks.com/help/releases/R2024b/matlab/ref/surf.html
Hope this helps!
0 comentarios
Ver también
Categorías
Más información sobre Surface and Mesh Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!