What Should Happen when a Live Script is Executed from the Command Line?

I have a Live Script myscript.mlx. I accidentally used myscript as a command on the command line
>> myscript
As soon a I hit enter, I realized that I had no idea what was suppose to happen? Should the LiveScript editor open with the script executing? Something else?
As it turned out, nothing happened. I got the "Busy" status in the lower left of the Matlab window. Waited a while and when nothing seemed to be happening I tried to get back control with ctrl-c, and opening the Live editor and clicking on Stop. Nothing happened. Eventually had to end the Matlab process (Win 10).

 Accepted Answer

It should run your script. Any lines of code without a semicolon will print their output to the command window, and any figures will open in figure windows.
Just note, though, that for figures, live scripts keep reusing the same figure unless you explicitly tell it to create a new figure. Inside the live script, you will see a snapshot of your figure anytime you modify it. However, when you run the live script from the command window, only the final figure is displayed.

1 Comment

OK. I just quit Matlab, restarted, and tried it again. It worked exactly as you said. No idea what was different this time.

Sign in to comment.

More Answers (0)

Categories

Products

Release

R2021b

Asked:

on 20 Feb 2022

Commented:

on 20 Feb 2022

Community Treasure Hunt

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

Start Hunting!