How to get coordinates values X, Y, Z from the Meshed file in matlab?

I have a meshed bone model(stl file). I have to extract data points (X,Y, Z coordinates) from the model which has 4000 nodes.
Can anyone suggest some idea to proceed?

 Accepted Answer

Something like this
TR = stlread('tristltext.stl');
x = TR.Points(:,1);
y = TR.Points(:,2);
z = TR.Points(:,3);

7 Comments

Hi, Thanks for your response.
I am getting an error like "Reference to non-existent field 'Points'".
we should define the term "points" before. Do you have any suggestions for this.
Points is a field in the struct returned by stlread() and it should automatically exist inside TR.
Which MATLAB release are you using?
Can you show the output from the command window after running these lines
TR = stlread('tristltext.stl');
disp(TR)
Hi, It gives
faces: [10114×3 double]
vertices: [30342×3 double]
In this can, you can write
TR = stlread('tristltext.stl');
x = TR.vertices(:,1);
y = TR.vertices(:,2);
z = TR.vertices(:,3);
OP was using FEX #22409 or a related third-party decoder. It has limitations and is not necessary in R2019a.
Since R2018b, MATLAB has built-in STL tools as described in the initial answer.
For legacy versions needing third-party tools, I'd recommend these tools over #22409. This explains why.

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!