Can I export 3D graphics to the .WML (VRML 2.0) or .OBJ file formats?

53 views (last 30 days)
I have a 3D surface in MATLAB that I would like to export to either .WML or .OBJ so that it can then be read into another CAD program I am running.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 30 Apr 2021
Edited: MathWorks Support Team on 30 Apr 2021
To export 3D MATLAB graphics to the .WML file format, you can consider using the VRML function that is built-into MATLAB. The code snippet below illustrates exporting a 3D planar surface to this format. To reproduce this, execute the following:
% Create random 3D data
xran=rand(10,3);
% Create line plot of these points (you can generate the same with surfaces as well)
figure, plot3(xran(:,1),xran(:,2),xran(:,3)), grid on
% Export to VRML
vrml(gcf,'output.wrl')
You can replicate this example with a 3D surface by replacing the second step in the previous example with the example command 'membrane' and follow through with the same third step for exporting the image.
Exporting 3D graphics from MATLAB to the .OBJ file format is not directly supported. However, there are third-party users who have created functions that can do the same, an example of which is the SAVEOBJMESH function which is outlined here:
Note
The 'vrml' function was removed in R2014a. To use the function now, you must download it from FileExchange here:
Note that MathWorks does not guarantee or warrant the use or content of these third-party submissions. Any questions, issues, or complaints should be directed to the contributing author.
  2 Comments
Nathan S
Nathan S on 29 Apr 2016
Edited: MathWorks Support Team on 17 Feb 2021
The 'vrml' function was removed in R2014a. To use the function now, you must download it from file exchange here:
You may also export to (X)HTML using this file exchange submission:

Sign in to comment.

More Answers (1)

Himangshu Kalita
Himangshu Kalita on 11 Apr 2018
Hi, I am trying to use the vrml function to create a wrl file from a 3-D surface that I created in Matlab but its showing this error. graphicsversion will be removed in a future release. Use ~verLessThan('matlab','8.4.0') instead Does it mean it won't work in my Matlab version?
  1 Comment
hooman arad
hooman arad on 23 Dec 2020
hi. i have this problem too. if u can solved tell me.thanks
Himangshu Kalita

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!