File Exchange

image thumbnail


version 1.0 (5.17 KB) by Peter Corke
Extract m-file from LiveScript file


Updated 20 Sep 2016

View License

This function automatically extracts a MATLAB script from a Live Script (.mlx) file. Currently this can only be done through the GUI interface.

Cite As

Peter Corke (2020). LiveScript2m (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (12)

amin ya

Is there a way to do the reverse? zipping a folder and open it as mlx?

Peter Corke

Hi Uwe, I'm not an xslt guru, this was my first time attempt and it's probably an 80% solution and LiveScripts continue to evolve rapidly from what they were when this script was written. What is not translated properly?

Uwe Brauer

I just run your script on a mlx file and used matlab built in conversion. Yours is faster, but also does not translate the file entirely correct. I can send you an example.


Uwe Brauer

Uwe Brauer

Ok I found a solution
#! /bin/csh -f
unzip -p $1 matlab/document.xml | xsltproc /home/oub/ALLES/HGs/Matlab-init/livescript2m.xslt - > $2

Uwe Brauer

It seems not to work for me using matlab 2018b: I download the zip, unzip and in the same directory (which contains the .m and xls)
I run: live2script(hoja3) and obtain Attempt to execute SCRIPT hoja3 as a function:
so I try live2script(hoja3.mlx) and obtain Undefined variable "hoja3" or class "hoja3.mlx".
what do I miss?

Jan Kräck

Peter Corke

This conversion capability is also useful from outside MATLAB. I wrote a simple shell script which streams the .m file to stdout, just like cat does, for example

% mlxcat livescript.mlx

The xslt engine in preinstalled on Mac, is available for Linux, not sure about Windows. You need to adjust PATH to reflect where the livescript2m.xslt file that's part of this download ended up.

#! /bin/csh -f
unzip -p $1 matlab/document.xml | xsltproc PATH/livescript2m.xslt matlab/document.xml

Baptiste Ottino

@Jan Freyberg: yes, check it out:

doc matlab.internal.richeditor.openAndSave

I hope I'm not too late on this.

Baptiste Ottino

From Matlab 2016b at least, you can also use:

doc matlab.internal.richeditor.openAndConvert

It is the built-in function that does exactly that.


Jan Freyberg

Is there any way to have a function go the other way - create a Live Script from an m-file that's split into sections (%%-delimited)?


Very elegant!

MATLAB Release Compatibility
Created with R2016b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags