How to implement improper transfer function (s + 0.1) in simulink?

i have used the matlab guide of solving improper fractions in simulink which is as follows.
num=[1 0.1];
den=1;
[r,p,k]=residue(num,den);
sys1 = tf(r(1),[1,-p(1)])
sysk1 = k(1)*s;
sysk2 = k(2);
But it shows this error.
Solving_ImproperFun_simulink
Index exceeds the number of array elements (0).
Error in Solving_ImproperFun_simulink (line 4)
sys1 = tf(r(1),[1,-p(1)])

回答 (2 件)

Walter Roberson
Walter Roberson 2019 年 4 月 4 日

0 投票

Try it at the MATLAB level. You will see that r and p both come out empty, so indexing them at location 1 will not work.
Why not go directly to
sys1 = tf(num, den);

3 件のコメント

Talha Kaleem
Talha Kaleem 2019 年 4 月 4 日
Hello Walter Roberson. Thank you for answering my question.
Walter. I have tried it already. But when importing this function in simulink and running simulation following error message is shown.
Unsupported input format for From Workspace block 'untitled2/From Workspace'. Available formats are double non-complex matrix, a structure with or without time, or a structure with MATLAB timeseries as leaf nodes. All formats require the data to be finite (not Inf or NaN).
Walter Roberson
Walter Roberson 2019 年 4 月 4 日
You cannot import a transfer function. You would not be able to import a transfer function even if your original code had worked.
You cannot use the Transfer Function block in Simulink for this because that block requires that the denominator be at least as high a degree as the numerator.
You can use a State Space block: https://www.mathworks.com/help/simulink/slref/statespace.html . And you can use MATLAB ahead of time to work out what the matrices should be.
You can also use tf() inside a MATLAB Function Block. It is possible that you might need to coder.external() it, and you might not be able to use it with any Rapid Acceleration turned on.
Talha Kaleem
Talha Kaleem 2019 年 4 月 6 日
Walter. Thank you for your time.
Walter. I have tried matlab functions using coder.extrinsic but it also did't worked. I will also try the space state method to get out of problem.
On the other hand walter. I have found one other solution. Now instead of adding only (s + 1). I am adding (s + 1)/(0.0001s + 1). Because, in this case the pole is very far. Thus having almost negligible effect on system at higher frequencies.

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

Elio Sánchez G.
Elio Sánchez G. 2019 年 6 月 30 日

0 投票

You have to sum 2 signals: dr/dt + r (where "r" is the input signal). Just use three blocks: derivative, sum and gain.

1 件のコメント

Sina Dehbari
Sina Dehbari 2020 年 5 月 7 日
Dear Elio,
Could you send a picture of blokcs? I don't know how connect them

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

カテゴリ

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

質問済み:

2019 年 4 月 4 日

コメント済み:

2020 年 5 月 7 日

Community Treasure Hunt

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

Start Hunting!

Translated by