Import Matlab matrix to Simulink

조회 수: 60 (최근 30일)
Santos García Rosado
Santos García Rosado 2021년 3월 10일
댓글: Santos García Rosado 2021년 3월 10일
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
Santos García Rosado 2021년 3월 10일
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
Santos García Rosado 2021년 3월 10일
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에서 Simulink Functions에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by