Accessing Simulink Test Signals by Name

15 ビュー (過去 30 日間)
Danish Belal
Danish Belal 2019 年 10 月 17 日
コメント済み: Lorenzo Zustovich 2021 年 1 月 27 日
I am trying to create custom Criteria for a Simulation Test. The Test Result depends on the final value of some signals, as such I am trying to access said signals in the Custom Criteria Function.
Entering this code into the box...
outobj = TestResult.getOutputRuns;
x_pos = outobj.getSignalByIndex(1)
sltest_simout.get('x_vec_no_airdrag:1(1)')
sltest_simout.get('x_vec_no_airdrag')
...yields the following Output in the MATLAB Command Window.
x_pos =
Signal with properties:
ID: 49573
RunID: 49576
Name: 'x_vec_no_airdrag:1(1)'
Units: ''
DataType: 'double'
Complexity: "real"
ComplexFormat: "real-imaginary"
SampleTime: 'Continuous'
Model: 'Flugbahn_Ideal_Harness'
BlockPath: 'Flugbahn_Ideal_Harness/x_vec_no_airdrag'
FullBlockPath: 'Flugbahn_Ideal_Harness/x_vec_no_airdrag'
PortIndex: 1
Dimensions: 2
Channel: 1
Checked: 0
LineColor: [0.7180 0.2750 1]
LineDashed: '-'
InterpMethod: 'linear'
AbsTol: 0
RelTol: 0
TimeTol: 0
SyncMethod: 'union'
Values: [1×1 timeseries]
RootSource: ''
TimeSource: ''
DataSource: ''
ans =
[]
ans =
[]
However, the values returned by sltest_simout.get() are empty even though I am referring to them with their correct name. What am I doing wrong?

回答 (1 件)

Shishir Dwivedi
Shishir Dwivedi 2019 年 12 月 27 日
Hello Danish,
You might need to log the signal of interest to get the desired output. With prerequisite that "Signal logging" is on the model (Configuration parameters) and have provided some name to Signal logging variable (say, logsout).
log the signal "x_vec_no_airdrag" & use following command. This would give you test results in "Simulink.SimulationData.Signal" associated with "x_vec_no_airdrag"
outobj = TestResult.getOutputRuns;
x_pos = outobj.getSignalByIndex(1);
sigD = sltest_simout.get('logsout').get(x_pos.Name)
-Shishir.
  1 件のコメント
Lorenzo Zustovich
Lorenzo Zustovich 2021 年 1 月 27 日
Hi, I am interested in this topic.
Following what @Shishir Dwivedi suggested, how can the siganl be plot in the "Custom Criteria" pane in the Test Manager?
I used the following sintax, but does not work:
outobj = TestResult.getOutputRuns;
x_pos = outobj.getSignalByIndex(1);
sigD = sltest_simout.get('logsout').get(x_pos.Name);
% Plot WD feed cmd
plot(sigD);
grid on;
Best regards

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

カテゴリ

Help Center および File ExchangeTest Scripts についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by