Main Content

discardChanges

Discard data in memory and reload from connected data source

Since R2024a

    Description

    example

    discardChanges(connectionObj) discards the data in memory and reloads the data from the disk. The function returns 1 (true) if the discard was successful, and 0 (false) if the data connection was unable to revert the data from the disk.

    Examples

    collapse all

    Get value for variable x in the data dictionary.

    dd = Simulink.data.connect('myDictionary.sldd');
    dd.x 
    
    ans = 
        1

    Update variable x and get its new value.

    dd.x = dd.x + 2;
    dd.x 
    
    ans = 
        3
    

    Discard the changes to the data dictionary. Variable x is set back to its original value.

    success = discardChanges(dd);
    dd.x
    
    ans = 
        1

    Input Arguments

    collapse all

    Connection to data source, specified as a Simulink.data.DataConnection object.

    Version History

    Introduced in R2024a