1
votes

To all MATLAB and Simulink users,

I am doing a project and faced a problem importing data from a 'Signal From Workspace' in Simulink block.

My case:

I need to input 565 rows of 2 columns of data over a sample period of 22seconds into my Simulink block diagram. Each data sample time is 22/565.

However, the output data is a [565 x 2] which affects the input to the downstream Simulink blocks due to dimensions issue.

For example, Ideally, [1 x 2] output multiplies with [2 x 1] and repeat for 565 times over 22 seconds. Now, [565 x 2] output signal couldn't get through due to the dimension.

My attempts to solve the problem:

I tried using 'From workspace' instead of 'Signal From Workspace' but face some problems.

t=[0:22/565:22]' M (565 rows n 2 columns of values) data.time=t; data.signals.values = M; data.signals.dimensions=[565 2];

This error pops up when simulation is run:

*"Invalid structure-format variable specified as workspace input in 'test/From Workspace'. The structure 'dimensions'field must be a scalar or a vector with 2 elements. In addition, this field must be compatible with the dimensions of input signal stored in the 'values' field. " *

I greatly appreciate if anybody can provide insight/solutions/alternative method to my case.

THANK YOU!

Regards, KO

1

1 Answers

1
votes

It looks like you should be using

data.signals.dimensions = 2;

For example

>> t= linspace(0,10,1001)';
>> data.time = t;
>> data.signals.values = [sin(t) cos(t)];
>> data.signals.dimensions = 2;