roschach
roschach

Reputation: 9336

matrix multiplication in simulink

I am using simulink and I want to modify a signal using a matrix: what is the tool to obtain a block containing the matrix. Furthermore I would like to import the matrix from the workspace. Thanks.

Upvotes: 1

Views: 6674

Answers (1)

P0W
P0W

Reputation: 47794

For multiplying Matrix you can use product block, where can either do element-wise or matrix multiplication

enter image description here

For choosing data from workspace follow following example :

>> t1 = [1 :1:10]'; % for simulation time
>> m = magic(2); % Your matrix to be multipied
>> M = repmat(m,[1 1 length(t1)]); % repeat for length(t1) times
>> data.time = t1;
>> data.signals.values = M;
>> data.signals.dimensions =[2 2]; % Dimension of matrix

Now use data in the From Workspace block, as show in above snapshot.

Upvotes: 2

Related Questions