Main Content

Read 1-D Array and Structure From Workspace

This example shows how to read 1-D signals from the MATLAB workspace. When you open the model, the following code is executed by a PreLoadFcn callback:

t = 0.2 * [0:49]';
x = sin(t);
y = 10*sin(t);
wave.time = t;
wave.signals.values = [x,y];
wave.signals.dimensions =2;

In the top row of the model, the From Workspace block reads the array [t,x,y] from the MATLAB workspace.

In the bottom row of the model, the From Workspace block reads the same values from the workspace, but this time they are read from a structure named wave.