Automatically run Live Editor

15 ビュー (過去 30 日間)
Marco Bottani
Marco Bottani 2021 年 4 月 7 日
回答済み: Hrishikesh Borate 2021 年 4 月 23 日
Hi,
I am using Live Editor to generate reports for some tests.
So far I have written almost 50 test cases and for each one I have to click the "Run" button to compile the Live Editor report, and it would be great to automatically generate the report when the test is complete.
Is there any way to run the Live editor with commands? Or at least in an automated manner?
That would be really helpful.
Thanks a lot.
Marco

採用された回答

Hrishikesh Borate
Hrishikesh Borate 2021 年 4 月 23 日
Hi,
It’s my understanding that you are trying to automate the execution of live scripts. Assuming that all the live scripts are located in a particular directory, say sampleDirectory, following code demonstrates the automatic execution of live scripts, saving the live scrips and publishing the results as PDF files :-
import matlab.internal.liveeditor.LiveEditorUtilities
% specify path to the live scripts
filePath = fullfile(pwd,'sampleDirectory\');
cd(filePath);
% set the options according to the use case
options = struct('format','pdf','outputDir',filePath);
fileNames = dir(filePath);
for j = 1:size(fileNames,1)
if ~endsWith(fileNames(j).name,'.mlx')
continue;
end
matlab.internal.liveeditor.executeAndSave(fullfile(fileNames(j).folder,fileNames(j).name));
publish(fullfile(fileNames(j).folder,fileNames(j).name), options);
end
For more information, refer to publish.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by