How to load matrix variables as constant on Simulink?
36 次查看(过去 30 天)
显示 更早的评论
I am trying to load matrix variables on simulink as constant value from '.mat' file. Is it possible to load MATLAB variables on Simulink and use it as constant block value? All variables are N-d array. I found that there are several ways to load a variable on Simulink such as "From File Block" or "Input Port", but It did not work for my project.
0 个评论
采纳的回答
Jonas
2021-8-26
Load the .mat file into the Base Workspace of MATLAB, and in Simulink use the From Workspace block to enter the variable name there.
3 个评论
Jonas
2021-8-30
编辑:Jonas
2021-8-30
Ah, if your Matrix is just a time-invariant constant, you can use a 'Constant' block, and as a value enter the name of your matrix variable. The From Workspace block is to read and sample a variable from the base workspace, so indeed the purpose is different.
Like here, I have the variable 'decimation' in the base workspace and I can just use it in my model through a Constant block.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/724514/image.png)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simulink Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!