What does the output of stlread function represent?

%Is the output in (x,y,z) form? I read an stl file using stlread file and got a matrix with 744 columns and 3 rows.

 Akzeptierte Antwort

darova
darova am 6 Apr. 2020

0 Stimmen

Please see

1 Kommentar

DGM
DGM am 28 Jul. 2025
Bearbeitet: DGM am 28 Jul. 2025
Note that this answer refers to FEX #22409 or one of its derivatives, not the native MATLAB function stlread, which has been available since R2018b.
In fact, the question almost certainly refers to neither, but rather, it refers to FEX #6678.
All three of these tools have the exact same name, but they present data in completely different forms. This has turned into countless points of confusion across the forum. Users and responders all have mixed interpretations of what is even being used. We need to be clear about what we're using.
FEX #6678 was published in 2005, and it presents data in a relatively uncommon flat row-major format. OP has a model with 744 triangles, but they're only requesting a single output argument, so they're only receiving the x-coordinates of those triangles (3x744).
FEX #22409 was published and updated between 2008-2011, and presents data as unconsolidated face/vertex data either in a single FV struct, or as separate F,V lists. If OP had requested a single output, they would receive a scalar struct. If they had requested two outputs, they would have received a 744x3 face list and a 2232x3 vertex list. How do I know the number of vertices? It's strictly nfaces*3. That's a residual artifact of the file format and the fact that no effort was made to express connectivity beyond individual triangles.
The built-in stlread() returns a consolidated triangulation object. It will have 744 faces, but the number of unique vertices is dependent on topology, not the file format. Vertex connectivity spans the entire model, not just individual triangles.
Again, we need to be clear about what's being used, because this miscommunication has become common. There are many more STL readers and writers that are different. Many share the same or similar names.
OP was using R2017b. They didn't have built-in STL tools. Most readers now do. Use the tools you have instead of unknowingly shadowing them with incomplete old tools you don't actually need. If you need an old decoder, or you want to ask about FEX tools you downloaded, you need to actually disclose what you downloaded so that you don't need a unintentional FEX historian to infer your usage years after it's too late to help.
Let me be clear. I can't really fault @darova for this answer either; it's just an unfortunate consequence of the history of a preferable function name. Prior to R2018b, #22409 would have been the quasi-official Mathworks decoder. It was probably considered to be the canonical version by many even at the time of the question. I just want to reduce the propagation of confusion where I can.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Produkte

Version

R2017b

Tags

Gefragt:

am 6 Apr. 2020

Bearbeitet:

DGM
am 28 Jul. 2025

Community Treasure Hunt

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

Start Hunting!

Translated by