필터 지우기
필터 지우기

plot data X,y,z data as surface

조회 수: 1 (최근 30일)
Chiara Lanzi
Chiara Lanzi 2020년 6월 1일
댓글: Cris LaPierre 2020년 6월 2일
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
KSSV
KSSV 2020년 6월 1일
Attach your data.
Chiara Lanzi
Chiara Lanzi 2020년 6월 1일
Here the data

댓글을 달려면 로그인하십시오.

채택된 답변

Cris LaPierre
Cris LaPierre 2020년 6월 1일
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
Chiara Lanzi
Chiara Lanzi 2020년 6월 2일
Thank you!!!!Using 1000 for the grid I can see a very good improvement.
I didn't think that the grid was the problem or that it can affect so much the result. Well,now I know!!
Thank you, again.
Cris LaPierre
Cris LaPierre 2020년 6월 2일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Stress and Strain에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by