removeElement - Remove element from Simulink.SimulationData.Dataset
object - MATLAB ([original](https://in.mathworks.com/help/simulink/slref/simulink.simulationdata.dataset.removeelement.html)) ([raw](?raw))
Main Content
Remove element from Simulink.SimulationData.Dataset
object
Syntax
Description
Examples
Open the model LogDataDatasetFormat
. The model logs the data generated by three source blocks using the Dataset
format.
open_system("LogDataDatasetFormat.slx");
Simulate the model.
out = sim("LogDataDatasetFormat.slx");
By default, all logged data is returned in a single variable in the workspace as a Simulink.SimulationOutput
object.
out = Simulink.SimulationOutput:
tout: [101x1 double]
yout: [1x1 Simulink.SimulationData.Dataset]
SimulationMetadata: [1x1 Simulink.SimulationMetadata]
ErrorMessage: [0x0 char]
Check the contents of the Simulink.SimulationData.Dataset
object, yout
, that contains the logged output data.
yout = Simulink.SimulationData.Dataset 'yout' with 3 elements
Name BlockPath
___________ _________________________
1 [1x1 Signal] Sine Wave LogDataDatasetFormat/Out1
2 [1x1 Signal] Pulse LogDataDatasetFormat/Out2
3 [1x1 Signal] White Noise LogDataDatasetFormat/Out3
- Use braces { } to access, modify, or add elements using index.
Suppose you want to use the logged outputs as input for another simulation that does not use the White Noise
signal. To create a Dataset
object that you can load as external input data for that simulation, remove the White Noise
signal from the Dataset
object yout
. The White Noise
signal is the third signal in the Dataset
object, so specify the index as 3
. Then, rename the Dataset
object with the input data.
inputData = removeElement(yout,3); inputData.Name = "Input Data"; inputData
inputData = Simulink.SimulationData.Dataset 'Input Data' with 2 elements
Name BlockPath
_________ _________________________
1 [1x1 Signal] Sine Wave LogDataDatasetFormat/Out1
2 [1x1 Signal] Pulse LogDataDatasetFormat/Out2
- Use braces { } to access, modify, or add elements using index.
The value of the variable yout
remains unchanged. To modify the value of the variable yout
, assign the return from the removeElement
function back to yout
.
yout = removeElement(yout,3)
yout = Simulink.SimulationData.Dataset 'yout' with 2 elements
Name BlockPath
_________ _________________________
1 [1x1 Signal] Sine Wave LogDataDatasetFormat/Out1
2 [1x1 Signal] Pulse LogDataDatasetFormat/Out2
- Use braces { } to access, modify, or add elements using index.
The original Dataset
object in the SimulationOutput
object remains unchanged. To modify the data in the SimulationOutput
object, access the Dataset
object through the SimulationOutput
object instead of assigning it to a separate variable.
out.yout = removeElement(out.yout,3); out.yout
ans = Simulink.SimulationData.Dataset 'yout' with 2 elements
Name BlockPath
_________ _________________________
1 [1x1 Signal] Sine Wave LogDataDatasetFormat/Out1
2 [1x1 Signal] Pulse LogDataDatasetFormat/Out2
- Use braces { } to access, modify, or add elements using index.
Input Arguments
Index of element to remove from data set, specified as a scalar or a vector. To remove more than one element from the data set, specify a vector that contains the index for each element you want to remove.
Example: 1
Example: [1 3]
Output Arguments
Version History
Introduced in R2011a