Main Content

removeProperty

Remove property from Simulink.SimulationOutput object

    Description

    example

    simOut = removeProperty(simOut,prop) removes one or more properties prop from the Simulink.SimulationOutput object simOut.

    You can use the removeProperty function to remove data logging properties and custom properties from a Simulink.SimulationOutput object. You cannot use the removeProperty function to remove read-only properties.

    Examples

    collapse all

    A Simulink.SimulationOutput object represents the result of a simulation. The SimulationOutput object contains simulation metadata and all data logged from simulation. You can modify the contents of a Simulink.SimulationOutput object by adding or removing data logging and custom properties.

    Open the model LoggingBlocks, which logs several input signals using multiple logging techniques.

    • The output of the Sine Wave block is logged using signal logging.

    • The output of the Gain block is logged using a To Workspace block.

    • The outputs of the Gain, Chirp Signal, and Square Wave Generator blocks are logged using a Record block.

    • The output of the Square Wave Generator block is logged using output logging.

    The model is also configured to log time data.

    mdl = "LoggingBlocks"
    mdl = 
    "LoggingBlocks"
    
    open_system(mdl);

    The LoggingBlocks model

    Use the get_param function to save the values of the Amplitude and Frequency parameters of the Sine Wave block. Store the values in the structure sinConfig.

    sinConfig.sinAmp = get_param(strcat(mdl,"/Sine Wave"),"Amplitude");
    sinConfig.sinFreq = get_param(strcat(mdl,"/Sine Wave"),"Frequency");

    Simulate the model.

    simOut = sim(mdl);

    The simulation results contain all logging variables created in simulation. Use the who function to get a list of properties you can modify.

    props = who(simOut)
    props = 5x1 cell
        {'logsout'  }
        {'recordout'}
        {'simout'   }
        {'tout'     }
        {'yout'     }
    
    

    For this simulation, suppose you want to save only the data for the signal path related to the Sine Wave block. Use the removeProperty function to remove the recordout and yout properties.

    simOut = removeProperty(simOut,["recordout" "yout"]);
    who(simOut)
    This Simulink.SimulationOutput object contains these editable properties:
    
        logsout    simout    tout    
    

    You can also add data to a Simulink.SimulationOutput object by adding your own properties to the object or by using the setUserData function to specify the value for the UserData property on the Simulink.SimulationMetadata object.

    Suppose you want to save the parameter values for the Sine Wave block as a property on the Simulink.SimulationOutput object. Add the property SineWaveParameters by using dot notation the same way you add a field to a structure.

    simOut.SineWaveParameters = sinConfig;
    who(simOut)
    This Simulink.SimulationOutput object contains these editable properties:
    
        SineWaveParameters    logsout    simout    tout    
    

    Input Arguments

    collapse all

    Simulation results, specified as a Simulink.SimulationOutput object.

    Property to remove, specified as a string, a string array, a character vector, or a cell array of character vectors. To delete a single property, specify the name of the property as a string or a character vector. To delete multiple properties, specify the names of the properties as a string array or a cell array of character vectors.

    You cannot remove read-only properties, such as the SimulationMetadata and ErrorMessage properties, from a Simulink.SimulationOutput object. To get a list of properties that you can remove, use the who function.

    Example: simOut = removeProperty(simOut,"MyProperty")

    Data Types: char | string

    Output Arguments

    collapse all

    Simulation results with property removed, returned as a Simulink.SimulationOutput object.

    Tips

    • Modifying the contents of simulation results in a Simulink.SimulationOutput object using a post-simulation function can be useful in parallel computing workflows. For example, you can remove data logging properties and send only a subset of logged data from the worker back to the client. For more information, see setPostSimFcn.

    • Use the removeElement function to remove logged data from a Simulink.SimulationData.Dataset object.

    Version History

    Introduced in R2019a