How to automatically run the script from a m-file when launching through double clicks?

20 ビュー (過去 30 日間)
Caster John Tabora
Caster John Tabora 2021 年 11 月 22 日
コメント済み: Walter Roberson 2022 年 2 月 10 日
I'm creating a project where I use python to centralize all my programs used for a particular device.
I would like to optimize the efficiency of the program, however, when the m-file is launched, the user still needs to press the run button from the toolbar. How do I automatically run the script file without pressing anything/typing anything into the command window? How do I automatically close the program at the end of the script file as well?
  1 件のコメント
Walter Roberson
Walter Roberson 2022 年 2 月 10 日
There is a possibility that it could be done.
The editor has to be opened on the file in order to display the file to get it in the state where it could be Run from the title bar. Maybe there would be a way to use startup.m to hook in a listener to the editor to catch opening the file.
If it turns out that opening the file is done before running startup.m then startup.m could query the list of files open in the editor, and then ask to run the file.

サインインしてコメントする。

回答 (1 件)

Rishabh Singh
Rishabh Singh 2022 年 2 月 10 日
Hi,
As per my understanding, you wish to run a MATLAB script without using the run command from the toolbar. An alternative to this is using "run" command to execute any script. Also if you wish to close the progam at the end of the running of your script, then either "quit" or "exit" command added at the very end of your script will perform the task.
Hope this helps.

カテゴリ

Help Center および File ExchangeEnvironment and Settings についてさらに検索

タグ

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by