setUserString - Add string to metadata in Simulink.SimulationOutput
object - MATLAB ([original](https://www.mathworks.com/help/simulink/slref/simulink.simulationoutput.setuserstring.html)) ([raw](?raw))
Main Content
Add string to metadata in Simulink.SimulationOutput
object
Syntax
Description
[simOut](#mw%5F934ad31e-0fb6-4898-a173-746c5633a73e) = setUserString([simOut](#mw%5F934ad31e-0fb6-4898-a173-746c5633a73e),[str](#mw%5Fcad05dd4-a3db-4894-8837-de05c6b67025))
adds the text str
to the metadata stored in theSimulink.SimulationOutput
object simOut
.
You can use this function to add a description about the simulation that produced theSimulink.SimulationOutput
object or a description of the results.
Examples
The SimulationMetadata
property of the Simulink.SimulationOutput
object contains simulation metadata stored as a Simulink.SimulationMetadata
object. You can specify additional information about the simulation in the UserData
and UserString
properties of the SimulationMetadata
object. For example, you can save the Simulink.SimulationInput
object used to configure the simulation in the UserData
property and specify the UserString
as a description of the simulation purpose, configuration, or results.
Open the model ex_sldemo_bounce
. This model simulates the motion of a bouncing ball based on an initial velocity.
mdl = "ex_sldemo_bounce"; open_system(mdl)
Create a Simulink.SimulationInput
object to configure a simulation of the model. Use the setBlockParameter
function to specify the initial velocity as 20
.
simin = Simulink.SimulationInput(mdl); simin = setBlockParameter(simin,"ex_sldemo_bounce/Initial Velocity",... "Value","20");
Simulate the model.
Use the setUserData
function to add the Simulink.SimulationInput
object to the simulation metadata.
out = setUserData(out,simin);
Use the setUserString
function to add a description for the simulation.
out = setUserString(out,"Initial Velocity = 20");
View the simulation metadata. The UserString
and UserData
properties have the values specified using the setUserString
and setUserData
functions.
simmetadata = out.SimulationMetadata
simmetadata = SimulationMetadata with properties:
ModelInfo: [1×1 struct]
TimingInfo: [1×1 struct]
ExecutionInfo: [1×1 struct]
UserString: "Initial Velocity = 20"
UserData: [1×1 Simulink.SimulationInput]
Input Arguments
Text to add to metadata, specified as a string or a character vector.
Data Types: char
| string
Output Arguments
Simulation results with text added, returned as a Simulink.SimulationOutput object. The SimulationOutput
object stores simulation metadata as a Simulink.SimulationMetadata object. The text you specify is added to theUserString
property of theSimulink.SimulationMetadata
object.
simMetadata = simOut.SimulationMetadata; userString = simMetadata.UserString;
Version History
Introduced in R2015a