Import Matlab matrix to Simulink

38 vues (au cours des 30 derniers jours)
Santos García Rosado
Santos García Rosado le 10 Mar 2021
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 commentaires
Fangjun Jiang
Fangjun Jiang le 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 le 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

Connectez-vous pour commenter.

Réponse acceptée

Fangjun Jiang
Fangjun Jiang le 10 Mar 2021
  1 commentaire
Santos García Rosado
Santos García Rosado le 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.

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by