Accessing Simulink Test Signals by Name

15 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Test Scripts 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by