Effacer les filtres
Effacer les filtres

Accessing Simulink Test Signals by Name

20 vues (au cours des 30 derniers jours)
Danish Belal
Danish Belal le 17 Oct 2019
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?

Réponses (1)

Shishir Dwivedi
Shishir Dwivedi le 27 Déc 2019
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 commentaire
Lorenzo Zustovich
Lorenzo Zustovich le 27 Jan 2021
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

Connectez-vous pour commenter.

Produits


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by