gktscrk gktscrk - 4 months ago 39
LaTeX Question

Exporting a 3D Line (Plot3) from Matlab to U3D/LaTeX

What I am trying to do is export a figure as STL, U3D, anything which would get me a step further into including these plots as 3D PDFs in a LaTeX document. From the reading I have done, it is straightforward to convert a surface/quiver into U3D either using this add-on or through a STL conversion.

However, both of these approaches seem incapable of converting a three-dimensional line such as the one I have:

temp = [15.2697 671.323 -9.91231;
26.9127 766.25 -9.73684;
40.6373 863.993 -9.50037;
56.4426 963.955 -9.21152;
74.4579 1069 -8.96309;
94.902 1177 -8.75421;
117.824 1287 -8.48337;
143.176 1400 -8.20126;
171.07 1515 -7.93761;
201.032 1629 -7.66941;
232.849 1742 -7.57231;
265.95 1855 -7.5369;
298.406 1964 -7.4525;
334.686 2073 -7.3278;
294.999 1942 -7.4535;
235.956 1723 -7.90447;
203.222 1576 -8.31706;
180.908 1462 -8.70754];

Firstly, it sounds impossible for me to use the STL approach as I would have to triangulate data which cannot be triangulated (compared to a surface).

The first add-on I mentioned above, however, thinks that this is a quiver plot and then fails saying that it needs either a surface or a patch object (though the readme does suggest lines are also possible).

Overall, however, both of these feel too complicated for something which should have a driver inside Matlab. Am I missing an obvious simple solution for this problem?


I managed to get around this by using the Export figure to 3D interactive PDF with a line instead of the plot3. There's considerable loss of quality from looking at my lines, with there being not uncommon breaks in them which did not exist in the plot3version but this at least solved the original problem.

For now, this would be the way I'd suggest anyone to approach this. For a working example, the below should be of assistance:


Using the same set of data as before.

Lastly, note that at least with Matlab R2016b the linked U3D convertor does not work properly and some manual edits are required (until the source code gets fixed). The author's Github site details these changes.