Full surface from scatter by griddata!!!

조회 수: 1 (최근 30일)
Le Xuan Thang
Le Xuan Thang 2022년 6월 10일
댓글: Le Xuan Thang 2022년 6월 11일
A = [0. 0. 1.
0. 0.07124705 0.9974587
0. 0.15205718 0.9883717
0. 0.24253563 0.9701425
0. 0.34174306 0.93979342
0. 0.4472136 0.89442719
0. 0.5547002 0.83205029
0. 0.65850461 0.75257669
0. 0.75257669 0.65850461
0. 0.83205029 0.5547002
0. 0.89442719 0.4472136
0. 0.93979342 0.34174306
0. 0.9701425 0.24253563
0. 0.9883717 0.15205718
0. 0.9974587 0.07124705
0. 1. 0.
0.07124705 0. 0.9974587
0.07647191 0.07647191 0.99413485
0.08192319 0.16384638 0.9830783
0.08737041 0.26211122 0.96107446
0.09245003 0.36980013 0.92450033
0.09667365 0.48336824 0.87006284
0.09950372 0.59702231 0.79602975
0.10050378 0.70352647 0.70352647
0.09950372 0.79602975 0.59702231
0.09667365 0.87006284 0.48336824
0.09245003 0.92450033 0.36980013
0.08737041 0.96107446 0.26211122
0.08192319 0.9830783 0.16384638
0.07647191 0.99413485 0.07647191
0.07124705 0.9974587 0.
0.15205718 0. 0.9883717
0.16384638 0.08192319 0.9830783
0.17609018 0.17609018 0.968496
0.18814417 0.28221626 0.94072087
0.19900744 0.39801488 0.89553347
0.20739034 0.51847585 0.82956136
0.21199958 0.63599873 0.74199852
0.21199958 0.74199852 0.63599873
0.20739034 0.82956136 0.51847585
0.19900744 0.89553347 0.39801488
0.18814417 0.94072087 0.28221626
0.17609018 0.968496 0.17609018
0.16384638 0.9830783 0.08192319
0.15205718 0.9883717 0.
0.24253563 0. 0.9701425
0.26211122 0.08737041 0.96107446
0.28221626 0.18814417 0.94072087
0.30151134 0.30151134 0.90453403
0.31799936 0.42399915 0.8479983
0.32929278 0.5488213 0.76834982
0.33333333 0.66666667 0.66666667
0.32929278 0.76834982 0.5488213
0.31799936 0.8479983 0.42399915
0.30151134 0.90453403 0.30151134
0.28221626 0.94072087 0.18814417
0.26211122 0.96107446 0.08737041
0.24253563 0.9701425 0.
0.34174306 0. 0.93979342
0.36980013 0.09245003 0.92450033
0.39801488 0.19900744 0.89553347
0.42399915 0.31799936 0.8479983
0.44444444 0.44444444 0.77777778
0.45584231 0.56980288 0.68376346
0.45584231 0.68376346 0.56980288
0.44444444 0.77777778 0.44444444
0.42399915 0.8479983 0.31799936
0.39801488 0.89553347 0.19900744
0.36980013 0.92450033 0.09245003
0.34174306 0.93979342 0.
0.4472136 0. 0.89442719
0.48336824 0.09667365 0.87006284
0.51847585 0.20739034 0.82956136
0.5488213 0.32929278 0.76834982
0.56980288 0.45584231 0.68376346
0.57735027 0.57735027 0.57735027
0.56980288 0.68376346 0.45584231
0.5488213 0.76834982 0.32929278
0.51847585 0.82956136 0.20739034
0.48336824 0.87006284 0.09667365
0.4472136 0.89442719 0.
0.5547002 0. 0.83205029
0.59702231 0.09950372 0.79602975
0.63599873 0.21199958 0.74199852
0.66666667 0.33333333 0.66666667
0.68376346 0.45584231 0.56980288
0.68376346 0.56980288 0.45584231
0.66666667 0.66666667 0.33333333
0.63599873 0.74199852 0.21199958
0.59702231 0.79602975 0.09950372
0.5547002 0.83205029 0.
0.65850461 0. 0.75257669
0.70352647 0.10050378 0.70352647
0.74199852 0.21199958 0.63599873
0.76834982 0.32929278 0.5488213
0.77777778 0.44444444 0.44444444
0.76834982 0.5488213 0.32929278
0.74199852 0.63599873 0.21199958
0.70352647 0.70352647 0.10050378
0.65850461 0.75257669 0.
0.75257669 0. 0.65850461
0.79602975 0.09950372 0.59702231
0.82956136 0.20739034 0.51847585
0.8479983 0.31799936 0.42399915
0.8479983 0.42399915 0.31799936
0.82956136 0.51847585 0.20739034
0.79602975 0.59702231 0.09950372
0.75257669 0.65850461 0.
0.83205029 0. 0.5547002
0.87006284 0.09667365 0.48336824
0.89553347 0.19900744 0.39801488
0.90453403 0.30151134 0.30151134
0.89553347 0.39801488 0.19900744
0.87006284 0.48336824 0.09667365
0.83205029 0.5547002 0.
0.89442719 0. 0.4472136
0.92450033 0.09245003 0.36980013
0.94072087 0.18814417 0.28221626
0.94072087 0.28221626 0.18814417
0.92450033 0.36980013 0.09245003
0.89442719 0.4472136 0.
0.93979342 0. 0.34174306
0.96107446 0.08737041 0.26211122
0.968496 0.17609018 0.17609018
0.96107446 0.26211122 0.08737041
0.93979342 0.34174306 0.
0.9701425 0. 0.24253563
0.9830783 0.08192319 0.16384638
0.9830783 0.16384638 0.08192319
0.9701425 0.24253563 0.
0.9883717 0. 0.15205718
0.99413485 0.07647191 0.07647191
0.9883717 0.15205718 0.
0.9974587 0. 0.07124705
0.9974587 0.07124705 0.
1. 0. 0. ];
x = A(:,1);
y = A(:,2);
z = A(:,3);
[xq,yq] = meshgrid(0:.01:1);
vq = griddata(x,y,z,xq,yq,'linear');
mesh(xq,yq,vq)
hold on
scatter3(x,y,z,'filled')
view(135,45)
This is picture I get: (Figure 1)
This is picture I want to get:(Figure 2)
The line above is code I try to run full surface but I only get (figure(1)) The edge in bottom do not have. So how can i get Full surface like this from this code. Any other solution in this case??? Thank you.

채택된 답변

Bjorn Gustavsson
Bjorn Gustavsson 2022년 6월 10일
편집: Bjorn Gustavsson 2022년 6월 10일
This is "just" a pixellation-problem. You can see how it comes about by varying the resolution of your grid:
[xq,yq] = meshgrid(0:.001:1);
vq = griddata(x,y,z,xq,yq,'linear');
subplot(2,2,1)
surf(xq,yq,vq),shading flat
view(0,90)
hold on
scatter3(x,y,z,8,'r','filled')
subplot(2,2,2)
[xq,yq] = meshgrid(0:.01:1);
vq = griddata(x,y,z,xq,yq,'linear');
surf(xq,yq,vq),shading flat
view(0,90)
hold on
scatter3(x,y,z,8,'r','filled')
subplot(2,2,3)
[xq,yq] = meshgrid(0:.1:1);
vq = griddata(x,y,z,xq,yq,'linear');
surf(xq,yq,vq),shading flat
view(0,90)
hold on
scatter3(x,y,z,8,'r','filled')
Alternatively you could use trisurf:
tri = delaunay(x,y);
tr = triangulation(tri, x(:), y(:), z(:));
subplot(2,2,4)
trisurf(tr)
view(0,90)
shading flat
HTH
  댓글 수: 4
Bjorn Gustavsson
Bjorn Gustavsson 2022년 6월 10일
These are all matlab-provided functions, so for full documentation just check the help and online-docs. The delaunay-function does a delaunay-triangulation of your points. The call to triangulate is just to add the z-component to the triangulation, and the trisurf call I got from the example in the trisurf help.
Le Xuan Thang
Le Xuan Thang 2022년 6월 11일
Oh i see. Thank you a lot

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by