plot data X,y,z data as surface
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Chiara Lanzi
am 1 Jun. 2020
Kommentiert: Cris LaPierre
am 2 Jun. 2020
Hi all.
I am trying to plot stress values with matlab. My file dataset is with 3 columns: x_coord, y_coord, stress (which correspond to the stress values).
I tried to use scatter but, obviously, it plot the data as a point which is not exactly what I want.
I used scatterinterpolant+surf and imagesc but the colorbar numbers are different from the real data, so I am not sure I am doing the right thing.
F = scatteredInterpolant(x_axis, y_axis,zvalue);
min_x_axis = min(x_axis);
min_y_axis = min(y_axis);
max_x_axis = max(x_axis);
max_y_axis = max(y_axis);
x= linspace(min_x_axis, max_x_axis, 100);
y = linspace(min_y_axis, max_y_axis, 100);
[X, Y] = ndgrid(x, y);
D = F(X, Y);
surf(X, Y, D, 'edgecolor', 'none');
Thanks to all who can help me.
2 Kommentare
Akzeptierte Antwort
Cris LaPierre
am 1 Jun. 2020
Your code looks good. How exact are you expecting the colorbar to be? You've interpolated the data, so it's not going to exactly match.
4 Kommentare
Cris LaPierre
am 2 Jun. 2020
Just one follow up then. Your grid does not have to be equally spaced. Most of this surface can be generated with only a few points. You really only need the grid to be finer around your points of interest. If you can get the grid to exactly land on your extreme points, you can get the same max/min values.
min_x_axis = -50000
max_x_axis = 4.9936e+04
min_y_axis = -5.0000e+04
max_y_axis = 0
min_zvalue = -16.2749
max_zvalue = 1.5124
I created a scatter3 plot and used the data tip tool to identify the X and Y coordinates of the peaks. I added those to the 100x100 grid and got the same max/min values.
...
x= linspace(min_x_axis, max_x_axis); % default is 100 points
y = linspace(min_y_axis, max_y_axis);
% Add points of interest to the grid
x = sort([x -4300 0 4273])
y = sort([y -10400 -10000 -9982 -9600 -5000 0])
.
.
.
And the corresponding min/max values of the surface
min_X = -50000
max_X = 4.9936e+04
min_Y = -5.0000e+04
max_Y = 0
min_D = -16.2465
max_D = 1.5124
Of course, this is a manual process.
One item to be aware of still. The bump on the top is actually 2 separate peaks. I can see this when I explore the scatter3 plot. However, I could not get it to appear in the surface, again likely due to approximation errors when interpolating.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Surface and Mesh Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!