Main Content

clear

Clear variables from file adapter tester object

Since R2022b

    Description

    example

    clear(testerObj) clears the workspace variables from the Simulink.data.adapters.AdapterDataTester object testerObj. The tester object provides functions for testing a custom external file adapter derived from the Simulink.data.adapters.BaseMatlabFileAdapter base class.

    Examples

    collapse all

    Clear the workspace variables from a Simulink.data.adapters.AdapterDataTester object after using the object to test an XML file adapter derived from a Simulink.data.adapters.BaseMatlabFileAdapter base class. For an example of an XML file adapter, see .

    The example uses an XML file test.xml with the following format.

    <customerData>
    <x>10</x>
    <y>15</y>
    </customerData>

    Create an instance of your file adapter.

    adapterInstance = myXMLAdapter;
    

    Create an instance of the file adapter tester object using the test file specified above.

    adapterTester = Simulink.data.adapters.AdapterDataTester(adapterInstance,...
                                                             'test.xml','XML Adapter');

    Use adapterTester to read the data from your XML file. Then, check the data in the WorkspaceVariables property.

    readFromSource(adapterTester);
    variables = adapterTester.WorkspaceVariables
    
    variables = 
      Map with properties:
        Count: 2
        KeyType: char
        ValueType: double
    

    Check the data in the WorkspaceVariables map object.

    variables.keys
    
    ans = 
      1x2 cell array
        {"x"}  {"y"}

    Finally, clear the workspace variables.

    clear(adapterTester);

    Input Arguments

    collapse all

    File adapter tester, specified as a Simulink.data.adapters.AdapterDataTester object.

    Version History

    Introduced in R2022b