Import Matlab matrix to Simulink

40 次查看(过去 30 天)
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 个评论
Fangjun Jiang
Fangjun Jiang 2021-3-10
use a samll matrix as an example, explain how you did it and what is your expectation
Santos García Rosado
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

请先登录,再进行评论。

采纳的回答

Fangjun Jiang
Fangjun Jiang 2021-3-10
  1 个评论
Santos García Rosado
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Sources 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by