Check if a script has been run during this session

Hello,
I have an initialization script called activate.p that needs to be run before I can send commands to the instrument I'm using. I want to put an if statement at the beginning of all my data acquisition scripts that checks whether activate.p has been run during the current Matlab session, and runs it if not.
Is there a function to store the command history of the current session as an array that I can then check to see if it includes activate.p? I found the commandhistory command, but this doesn't return anything.

 採用された回答

the cyclist
the cyclist 2021 年 9 月 4 日
編集済み: the cyclist 2021 年 9 月 4 日

1 投票

Your command history is stored in an XML file, in your preferences directory. See this question/answer for details.

その他の回答 (1 件)

Jan
Jan 2021 年 9 月 4 日

1 投票

Create your own function:
function myActivate
persistent called
if isempty(called)
activate();
caslled = true;
end
end
Now simply call myActivate from any function, which requires that activate ran before.
This catchs even the evil clear all.

カテゴリ

ヘルプ センター および File ExchangeGet Started with MATLAB についてさらに検索

製品

リリース

R2021a

質問済み:

2021 年 9 月 4 日

編集済み:

2021 年 9 月 4 日

Community Treasure Hunt

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

Start Hunting!

Translated by