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 Structure From Workspace Using Model Sample Time

This example shows how to read a structure from the MATLAB workspace using a sample time specified in the From Workspace block. 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 = [];
wave.signals.values = [x,y];
wave.signals.dimensions =2;

The From Workspace block is configured as follows:

  • Sample time: 0.2

  • Interpolate data: off

  • Form output after final value by: Setting to zero

When you run the model, the From Workspace block reads the structure wave from the workspace. After the last time hit for which workspace data is available, the block outputs 0.