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.

Antworten (1)

Abhishek
Abhishek am 11 Jun. 2025

0 Stimmen

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 ‘scatterInterpolantand ‘surf methods, refer to the official MATLAB documentation:
Hope this helps!

Gefragt:

am 19 Feb. 2021

Beantwortet:

am 11 Jun. 2025

Community Treasure Hunt

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

Start Hunting!

Translated by