Run a script that opens Matlab and performs a function
2 views (last 30 days)
Show older comments
Jason
on 24 Feb 2016
Commented: Walter Roberson
on 25 Feb 2016
I want to be able to save a .m file to my desktop, and when I click it it will open matlab and run its self. Is there a way to do this?
0 Comments
Accepted Answer
Walter Roberson
on 24 Feb 2016
I don't know if it is impossible, since MS Windows allows some pretty odd behaviours to be configured on NTFS filesystems by using the Alternate Streams facilities. The .m file would effectively become the mount point for an application too run in... I suspect it might just be doable. I hesitate to guess at the amount of work involved.
On the other hand, you could so something very similar by creating a .bat that ran the function using the MATLAB startup flag "-r" followed by a MATLAB command. For example,
"C:\Program Files (x65)\MATLAB\R2018g\bin\intel\matlab.exe" -r "try run('C:\Users\Jason\Documents\MATLAB\Plan9\outer_space.m'); catch; quit"
2 Comments
Walter Roberson
on 25 Feb 2016
I forgot the 'end' on the 'try'
"C:\Program Files (x65)\MATLAB\R2018g\bin\intel\matlab.exe" -r "try run('C:\Users\Jason\Documents\MATLAB\Plan9\outer_space.m'); catch; end; quit"
More Answers (0)
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!