Accessing Simulink Test Signals by Name

조회 수: 20 (최근 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 CenterFile Exchange에서 Outputs에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by