how to have a matlab script give you a choice to automatically open other scripts

4 ビュー (過去 30 日間)
juan sanchez
juan sanchez 2025 年 1 月 23 日
編集済み: Les Beckham 2025 年 1 月 25 日
Hi, I want to have a starting script where it allows me to open a different script. For example I want the main script to ask me, do you wish to follow procedure A? and then if I select yes, then automatically the matlab will open script A. If the main script asks, do you wish procedure B? then Matlab opens automatically script B and so on. Then once in the secondary script, I will enter the parameters needed to perform the calculation. Thank you.

回答 (1 件)

Les Beckham
Les Beckham 2025 年 1 月 23 日
編集済み: Les Beckham 2025 年 1 月 23 日
That seems like a questionable workflow. Nevertheless, this should get you started.
% StartingScript.m
response = questdlg('Open ScriptA?');
if strcmp(response, 'Yes')
edit('ScriptA.m')
end
% and so on
Read the documentation for questdlg for more details on how you can adapt it to your preferences.
  2 件のコメント
juan sanchez
juan sanchez 2025 年 1 月 24 日
Thank you very much. Just one more thing, how can I allow the secondary script to autorun so that I do not have to press run again when I run the primary script. Thank you.
Les Beckham
Les Beckham 2025 年 1 月 25 日
編集済み: Les Beckham 2025 年 1 月 25 日
I'm not sure I understand what you mean by "autorun".
Are you running the "primary script" in a loop and you want the selection of the secondary script to be repeated each time after the initial selection of which "secondary script" was made?
Your question is quite vague. More detail of what you are really trying to do would help.
In general, using scripts (especially for something that you want to run more than once) is bad practice.
If you have some processing that you want to do more than once with different inputs (data), you should use functions instead of scripts. I suggest that you read this help page Scripts vs. Functions.
Also, if you are just getting started with Matlab, I would highly recommend that you take a couple of hours to go through the free online tutorial: Matlab Onramp

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

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

タグ

製品


リリース

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by