removeElement
Remove element from Simulink.SimulationData.Dataset
object
Description
removes the elements at the indices specified by ds
= removeElement(ds
,ind
)ind
from the Simulink.SimulationData.Dataset
object ds
.
Examples
Remove Signal from Dataset
Object
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
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 = out.yout
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
ds
— Data set from which to remove element
Simulink.SimulationData.Dataset
object
Data set from which to remove element, specified as a Simulink.SimulationData.Dataset
object.
ind
— Index of element to remove from data set
scalar | vector
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
ds
— Data set with element removed
Simulink.SimulationData.Dataset
object
Data set with element removed, returned as a Simulink.SimulationData.Dataset
object.
Version History
Introduced in R2011a
Comando MATLAB
Hai fatto clic su un collegamento che corrisponde a questo comando MATLAB:
Esegui il comando inserendolo nella finestra di comando MATLAB. I browser web non supportano i comandi MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)