How can I import "Pulse-based" or "Frame-based" data into Simulink models?

8 views (last 30 days)
I have two models and I would like to feed the output of one model, "SourceModel", to the input of the second model, "DestinationModel".
In "SourceModel", I have a "Linear FM Waveform" block with the "Output Signal Format" set to "Pulses". I break that complex output into the real and imaginary portions, save the real portion into a MAT file called "Model1Out.mat", and then use a "To File" block with the "Save format" as "Array", as shown below:
In my second model, "DestinationModel", I would like to import the data saved in "Model1Out.mat" with a "From File" block, but I keep getting the following error:
"Invalid workspace variable specified as workspace input in 'DestinationModel/From File'. Time values must be non decreasing".  
I have tried loading the variable into the workspace to ensure the time values of the frames (first row of the matrix) are always increasing, and they are. I see the same error when I load the data into the workspace and use a "From Workspace" block. How can I get around this error?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 3 Feb 2023
Edited: MathWorks Support Team on 3 Feb 2023
To load data that was logged in array format using the "To File" block, transpose the array so that the time values are in a single column rather than a single row. This information is available in the "From Workspace" block documentation page, as follows:
Therefore, the solution to this issue is transposing the data (from the source model) in your workspace and loading the modified matrix into your destination model. To do this follow these steps:
  1. Load the data, lets call it "frame_data", into the workspace.
  2. Save the transposed data into a new variable using the "transpose" function:
    >> new_frame_data = transpose(frame_data)
    Please refer to the documentation page for the 'transpose' function below:
  3. Save the new variable to a MAT file.
  4. Load the MAT file into a "To File" block in your model, "DestinationModel".

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!