Remove buffering from frames of frame-based signal
convertToFrames( removes the buffering
from each frame of the frame-based signal that corresponds to the
sigObj. For example,
sigObj is a frame-based signal with 64-by-2 sample values. The
convertToFrames function interprets each 64-by-2 sample as 64 evenly
spaced 1-by-2 samples.
To convert the representation of a signal using the
function, the signal must have a discrete sample rate, and the sample values must be
nonscalar with fixed dimensions. The
convertToFrames function does not
support variable-size signals. The Simulation Data Inspector does not support converting
frames for imported data.
Interpret Data in Simulation Data Inspector as Frame-Based
Some applications buffer several samples of a signal into a frame to process with a single computation. When you log a frame-based signal to the Simulation Data Inspector, you can view and analyze the data for each frame using an array plot, or you can convert the representation of the signal data to undo the buffering. This example converts the representation of a frame-based signal from the model
Simulating the model for this example requires a license for DSP System Toolbox™. Converting frame-based data in the Simulation Data Inspector does not require a license for DSP System Toolbox.
Open the model
sfcndemo_frame. Then, mark the output from the A/D Converter block for logging and specify a name for the signal line.
open_system('sfcndemo_frame'); ADPort = get_param(find_system(gcs,'FindAll','on','name','A/D Converter'),'PortHandles'); set_param(ADPort.Outport,'DataLogging','on'); ADLine = get_param(ADPort.Outport,'Line'); set_param(ADLine,'Name','Noisy Signal');
Simulate the model.
out = sim('sfcndemo_frame','StopTime','99.84');
Simulink.sdi.getCurrentSimulationRun function to access the simulation data.
runObj = Simulink.sdi.getCurrentSimulationRun('sfcndemo_frame');
getSignalsByName function to access the
Simulink.sdi.Signal object for the A/D Converter block output signal named
NoisySig = getSignalsByName(runObj,'Noisy Signal');
Check the dimensions for a sample of the signal. The signal has two channels with a frame size of 64, resulting in sample values with dimensions 64-by-2. Because each sample is two-dimensional, the samples are concatenated along the third dimension, such that the time values align with the third dimension of the array of sample values.
ans = 1×2 64 2
To analyze the data for the signal over the duration of the simulation, use the
convertToFrames function to interpret the signal as frame-based.
Check the dimensions for a sample of the signal. After interpreting the signal as frame-based, each sample is a vector, and time aligns with the first dimension of the array of sample values.
ans = 1×2 1 2
Because the resulting signal has fewer than four elements in each sample, the Simulation Data Inspector also automatically converts the signal to channels. You can access the
Signal objects for each channel using the
Children property of the original
NoisyChannel1 = NoisySig.Children(1); NoisyChannel1.Name
ans = 'Noisy Signal(1)'
NoisyChannel2 = NoisySig.Children(2); NoisyChannel2.Name
ans = 'Noisy Signal(2)'
Each channel has scalar sample values.
ans = 1×2 1 1
sigObj — Signal with data to convert
Signal with data to convert, specified as a
convertToFrames function does not support variable-size
Introduced in R2021b