Import Matlab matrix to Simulink

40 views (last 30 days)
Hello community,
I'm trying to input a matrix variable saved from my matlab workspace into Simulink as an Input. The dimensions of my matrix are 14x262801. I'm using the From workspace block but for some reason it only outputs the last row of my matrix variable (size 1x262800).
Could someone explain me how to solve this problem and get the whole Matrix? I've tried changing some parameters from the block but I still can't manage to get the expected output.
Thank's for the help!
Santos
  2 Comments
Fangjun Jiang
Fangjun Jiang on 10 Mar 2021
use a samll matrix as an example, explain how you did it and what is your expectation
Santos García Rosado
Santos García Rosado on 10 Mar 2021
First of all, thanks for your help and time.
This is the Matrix I have in my workspace in Matlab:
MyMatrix = [0,1,2,3,4,5; 0,6,7,8,9,10; 0,11,12,13,14,15]
Then, I'm using the From Workspace block and writting the name of my variable "My Matrix"on the Data box.
The Output I'm expecting from that block in simulink is:
ExpectedOut = [1,2,3,4,5; 6,7,8,9,10; 11,12,13,14,15]'
However I'm getting the output of only the last row:
RealOut = [11,12,13,14,15]'
I'm not using Simulink for time simulations so I don't need a time vector. This is the reason why I write a zero at the beggining of each row.
Hope I made my self clear.
Thank you,
Santos

Sign in to comment.

Accepted Answer

Fangjun Jiang
Fangjun Jiang on 10 Mar 2021
  1 Comment
Santos García Rosado
Santos García Rosado on 10 Mar 2021
Thank you Fangjun! Nice and easy example! My code is working great now.
Just out of curiosity, why does t1 = 0.2 * [0:49]'; have to go from 0 to 49 and with that step in between? I've been trying the simulation with different steps a ranges and still works for me. What are the differences between using one step or another?
Thank you again for all your help.

Sign in to comment.

More Answers (0)

Products


Release

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!