How to import a transfer function from workspace into simulink?

I have a MATLAB script that creates two transfer functions and I want to use them in simulink. I could use a transfer function block and enter the function by hand, but I'm using numerous functions on numerous sets of data. I want to import the functions and automate the process as much as possible. Any help would be greatly appreciated.

2 件のコメント

henning
henning 2015 年 1 月 24 日
I actually have the same problem, and I checked the input arguments from the set_param documentation: set_param
I also checked the Parameters for the type Discrete Transfer Fcn (DiscreteTransferFcn) on this page Block-Specific Parameters
However, if I try to compile this code:
ProbSet3_Ex1c
set_param('ProbSet3_Ex1c/D','Denominator',[1 0 0],
'Numerator',[2 3 5],'SampleTime',1);
I always get this error:
Invalid setting in DiscreteTransferFcn block 'D' for parameter 'Denominator'
The same error appears, if I just try to change the SampleTime:
ProbSet3_Ex1c
set_param('ProbSet3_Ex1c/D','SampleTime',1);
Any ideas? Thanks a lot for helping!
Juan J. Rojas
Juan J. Rojas 2020 年 4 月 18 日
Try
ProbSet3_Ex1c
set_param('ProbSet3_Ex1c/D','Denominator',mat2str([1 0 0]),
'Numerator',mat2str([2 3 5]),'SampleTime',1);

サインインしてコメントする。

 採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 8 月 14 日
編集済み: Azzi Abdelmalek 2014 年 8 月 14 日

2 投票

Use set_param function

7 件のコメント

tom Diehl
tom Diehl 2014 年 8 月 14 日
That looks like what I've been looking for.
tom Diehl
tom Diehl 2014 年 8 月 14 日
Im having trouble getting the parameter name right. Could you give example of what you would type for the Numerator coefficients?
tom Diehl
tom Diehl 2014 年 8 月 14 日
nevermind, just had to leave off the coefficent part.
tom Diehl
tom Diehl 2014 年 8 月 14 日
Thank you
Azzi Abdelmalek
Azzi Abdelmalek 2014 年 8 月 14 日
Use
get_param('your_model_name/your_block_name','DialogParameters')
azam ghamari
azam ghamari 2019 年 9 月 26 日
Hi guys, I have the same problem when I want to use the "from workspace" block in simulink to bring data to simulink, actually I wanted to bring a transfer function from workspace to simulink, not a data, and I see that this block just have output port in, not any input , so I can not connect this block from input to another block. How can I do that?
Thank you
Rik
Rik 2019 年 9 月 28 日
@azam, instead of reposting your comment as a flag, have a read here and here. It will greatly improve your chances of getting an answer.
As far as I understand it, 'from workspace' can only load things from the base workspace. That means you can only use it to load data. Functions are not inside a workspace.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeSimulink についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by