trisurf to surf

5 visualizzazioni (ultimi 30 giorni)
Sven Koerner
Sven Koerner il 24 Feb 2011
Modificato: DGM il 5 Lug 2025
Hi, does anyone know a calculation for converting data from trisurf-plots in surf-plots?
If there is data TRI,X,Y and Z for generating a trisurf plot ( trisurf(Tri,X,Y,Z)), how can I convert the data to Xnew, Ynew and Znew, so that I get the same figure as with trisurf-function while doing surf(Xnew, Ynew, Znew)?
  1 Commento
Pavel Kolesnichenko
Pavel Kolesnichenko il 3 Lug 2019
Modificato: Pavel Kolesnichenko il 3 Lug 2019
I have similar question: is there a way to extract X,Y,Z-values from 'trisurf'-plot in the format that would be suitable to feed into 'surf'-command.

Accedi per commentare.

Risposte (2)

Sulaymon Eshkabilov
Sulaymon Eshkabilov il 1 Giu 2021
Here is a nice code developed by a matlab community user:
A few codes on surf and trisurf plotting options:
https://stackoverflow.com/questions/9170838/surface-plots-in-matplotlib
  1 Commento
DGM
DGM il 5 Lug 2025
Modificato: DGM il 5 Lug 2025
FEX surf2stl() is the opposite of what's needed. It takes simple gridded data compatible with surf() and triangulates it. We have triangulated data and want to turn it into gridded data compatible with surf.
The SO thread is about plotting (what we can assume is) scattered XYZ data as a surface -- basically an application where one would use griddata() (or if it's reshape() if it's actually gridded), but in python instead of MATLAB.

Accedi per commentare.


DGM
DGM il 5 Lug 2025
Modificato: DGM il 5 Lug 2025
The surf() tool works on gridded data. There's no reason to assume that triangulated F,V data is constrained to a grid. Is there an easy, convenient, and universally-applicable way to transform any arbitrary triangulation into gridded data? Not that I know of. For some simple cases, you might be able to use griddata(), but I'm not sure how you would apply that to any arbitrary geometry without complications or risking loss of fidelity.
For example, how would we reduce this triangulation to a concise gridded representation? It's not a single-valued function in any direction. It has holes, nonuniform resolution, and it consists of multiple connected components. I don't know how I would.
I think the better question is why you need to reduce the more descriptive F,V data into gridded data just to be able to use surf(). Given that this was in 2011, if the goal were to try to cram everything into gridded format in order to feed it to surf2stl(), then there was never any need. FEX #20922 has existed since 2008, and could take the F,V data directly without needing to grid it and then retriangulate it all over again for no benefit. Since R2018b, MATLAB has had stlwrite() in the base toolbox, so you don't even need #20922.
If there's some other goal, then I can only guess as to the goals and the shape of the triangulated data.

Community Treasure Hunt

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

Start Hunting!

Translated by