This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

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.