1
votes

Assume I have an arbitrary nx1 array in the Matlab workspace. How can I import this array as a source into Simulink and use cyclic repetition to extend the data beyond its final value?

I know the ‘From Workspace’ block in Simulink, and saw that it has an option called ‘Cyclic repetition’. However if I want to use my nx1 array I get the error message “Invalid variable specified as workspace input”.

1
If the answer below solves your problem, please consider accepting it.Cris Luengo

1 Answers

3
votes

To use the From workspace block your Matlab data must be in a specific format. E.g. for a sine wave signal you need to use a struct of the following format:

y.signals.values=sin(0:0.01:10*pi)';
y.signals.dimensions=1;
y.time = [ ];

Then in the From Workspace block make sure you set the correct variable for data, uncheck Interpolate data and set Cyclic repetition like this

Required settings in the From Workspace block

Now you can verify that the correct data was imported from the workspace by simply feeding it through to a scope:

Verify imported data using simple model

The resulting output looks like this and confirms that the From Workspace block worked as intended as it repeats the original data until 10000s:

Output until 10000 seconds