Full surface from scatter by griddata!!!

1 visualización (últimos 30 días)
Le Xuan Thang
Le Xuan Thang el 10 de Jun. de 2022
Comentada: Le Xuan Thang el 11 de Jun. de 2022
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.

Respuesta aceptada

Bjorn Gustavsson
Bjorn Gustavsson el 10 de Jun. de 2022
Editada: Bjorn Gustavsson el 10 de Jun. de 2022
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 comentarios
Bjorn Gustavsson
Bjorn Gustavsson el 10 de Jun. de 2022
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 el 11 de Jun. de 2022
Oh i see. Thank you a lot

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Surface and Mesh Plots en Help Center y File Exchange.

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by