Generating a Report for Simulink Data Inspector
5 ビュー (過去 30 日間)
古いコメントを表示
I'm using a script to check the signals of a sumulink model and get the results through the "Simulink.sdi.report" function.
The script is working, the only problem is that the results off the "Simulink.sdi.report" function aren't consistent.
This is the output that i desiere, withouth the two extra graphs below.

Unfortunatly i get sometimes other results like:

Those two runs are the exactly the same MATLAB Code with the same Simulink inputs and outputs.
The scripts gets the signals from a simple Simulink model that adds two consistent values (Constant1=3 , Constant=2).

This is the Code i Use:
%clear old sdi config
clear
Simulink.sdi.clear
sweep_values= 1;
model='signal_ID_trial'; %% set name of the model
load_system(model); %% load model
Simulink.sdi.markSignalForStreaming('signal_ID_trial/Constant',1,'on') %% Mark Signal Ports('Blockpath', Port, 'on/off')
Simulink.sdi.markSignalForStreaming('signal_ID_trial/Constant1',1,'on')
Simulink.sdi.markSignalForStreaming('signal_ID_trial/Sum',1,'on')
sim(model); %% Start der Simulation
% Get run IDs for most recent run
allIDs = Simulink.sdi.getAllRunIDs;
for i = 1:length(sweep_values)
%Choose run ID
runID = allIDs(end-(length(sweep_values)-i));
% Get Run object
signalRun = Simulink.sdi.getRun(runID);
%get Dataset Object
run_DSRef = signalRun.getDatasetRef;
%get List of Names form the Data
names = run_DSRef.getElementNames;
%get Signals with specifyed names and Ports
test_Sig1 = run_DSRef.getSignal('Sum:1');
test_Sig2 = run_DSRef.getSignal('Constant:1');
test_Sig3 = run_DSRef.getSignal('Constant1:1');
test_Sig1.plotOnSubPlot(1,1, true);
test_Sig2.plotOnSubPlot(1,1, true);
test_Sig3.plotOnSubPlot(1,1, true);
%%Simulink.sdi.view
end
% Specify report parameters
reportType = 'Inspect Signals';
reportName = 'Data_Report.html';
signalMetadata = [Simulink.sdi.SignalMetaData.Run, ...
Simulink.sdi.SignalMetaData.Line, ...
Simulink.sdi.SignalMetaData.BlockName, ...
Simulink.sdi.SignalMetaData.SignalName];
Simulink.sdi.report('ReportToCreate', reportType, 'ReportOutputFile', ...
reportName, 'ColumnsToReport', signalMetadata, 'ReportOutputFolder','$Filepath' ...
);
% System need to be saved befor closeing
save_system(model)
close_system(model)
The only thing that i noticed is, that when i have the SDI open while processing the Code, the Report has the same graphical layout as the SDI.
Setting the the layout of the SDI through the matlab script didnt change the output of the report.
How can i get a consistent report with the layout that i choose in the script
1 件のコメント
men8th
2022 年 11 月 4 日
I'm having similar problems with the custom snapshot class. Doesn't seem to work very well unless SDI is open and the charts are given time to render on screen. Perhaps Simulink report generator is more reliable.
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Sources についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!