Test iterations based on Table in Data Dictionary

조회 수: 2 (최근 30일)
Bryan Harper
Bryan Harper 2018년 3월 14일
답변: Bryan Harper 2018년 3월 29일
I'm interested on generating iterations for Simulink Test. The system under test operates based on a truth table, stored in a Data Dictionary. I want to generate iterations from the latest version stored in the data dictionary at the time of testing. If my data is as follows, I would want to generate and test 9 iterations:
table =
1 0 0
1 1 0
1 1 1
2 questions: Are scripted iterations (2 nested for loops) the best way to generate the test cases? If so, how do you use variables from the data dictionary? Currently I get "Undefined function or variable 'table'" if I try to store the data to pass to my nested loop.

채택된 답변

Bryan Harper
Bryan Harper 2018년 3월 29일
Just posting an update to my original question:
To clarify, my data dictionary is configured to not allow direct access from the base work space, for a variety of reasons.
As to using data from this dictionary to generate test iterations - I do this to avoid manual update to the test iterations if the data in the dictionary changes, as this data is used by multiple modules.
The answer on how to use this data is loading it into the base workspace at test run time.
Data is stored in "dictionary.sldd" under the "transitions" object. I pass this to my nested loop under the variable "Table"
% Open the dictionary object
DictObj = Simulink.data.dictionary.open('dictionary.sldd'); %open the dictionary object%
% Retrieve the section of the dictionary containing the data
SectObj = getSection(DictObj,'Design Data');
% Retrieve the data I care about
Entry = getEntry(SectObj,'transitions');
% Store the Entire entry
temp = getValue(Entry);
% Store the Value of the entry for generation of test iterations
Table = t.Value;
Hope this is helpful to someone else!

추가 답변 (1개)

Young Ma
Young Ma 2018년 3월 21일
Hi Bryan,
For the first question, the answer probably would be yes.
For the second question, I would suggest you to take a look at this document to configure parameters properly in data dictionary:
Also, it's possible that the variable is still in Base Workspace and not stored in Simulink Data Dictionary. In that case, you could try the following in scripted iterations:
v = evalin('base', 'var');
This example extracts the value of the variable var in the MATLAB base workspace and captures the value in the local variable v.

카테고리

Help CenterFile Exchange에서 Inputs에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by