Main Content


Remove buffering from frames of frame-based signal

Since R2021b



    convertToFrames(sigObj) removes the buffering from each frame of the frame-based signal that corresponds to the Simulink.sdi.Signal object sigObj. For example, suppose 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 convertToFrames 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.


    collapse all

    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 sfcndemo_frame.

    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.

    ADPort = get_param(find_system(gcs,'FindAll','on','name','A/D Converter'),'PortHandles');
    ADLine = get_param(ADPort.Outport,'Line');
    set_param(ADLine,'Name','Noisy Signal');

    Simulate the model.

    out = sim('sfcndemo_frame','StopTime','99.84');

    Use the Simulink.sdi.getCurrentSimulationRun function to access the simulation data.

    runObj = Simulink.sdi.getCurrentSimulationRun('sfcndemo_frame');

    Use the getSignalsByName function to access the Simulink.sdi.Signal object for the A/D Converter block output signal named Noisy Signal.

    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 Signal object.

    NoisyChannel1 = NoisySig.Children(1);
    ans = 
    'Noisy Signal(1)'
    NoisyChannel2 = NoisySig.Children(2);
    ans = 
    'Noisy Signal(2)'

    Each channel has scalar sample values.

    ans = 1×2
         1     1

    Input Arguments

    collapse all

    Signal with data to convert, specified as a Simulink.sdi.Signal object. The convertToFrames function does not support variable-size signals.

    Version History

    Introduced in R2021b