Not able to run a code given in documentation of tf function

I am trying to use the 'tf' function to get a transfer function however something seems to be wrong as I am just not able to use the function without an error about index popping up. I even tried this code given in the examples in documentation of the 'tf' function:
numerator = 1;
denominator = [2,3,4];
sys = tf(numerator,denominator)
And I get the error: Index in position 2 exceeds array bounds (must not exceed 1).
Can someone please help me? This is frustrating.

 採用された回答

madhan ravi
madhan ravi 2020 年 6 月 18 日

0 投票

clear tf

4 件のコメント

Niket Parikh
Niket Parikh 2020 年 6 月 18 日
I really cannot thank you enough! I am curious as to how did you know this? This seems like something I would have never figured this out myself. Is it your experience and knowledge or is it there in some documentation?
madhan ravi
madhan ravi 2020 年 6 月 18 日
You by mistake named a variable tf , so you see how much of a pain it gives ya ;)
Rik
Rik 2020 年 6 月 18 日
This is a fairly common mistake (it often happens with sum and image), so it is a reasonable guess given the error message.
You can check for things like this with the which command:
clc,clear
which tf -all
fprintf('\n And now again with a variable in the workspace:\n\n')
tf=0;
which tf -all
Niket Parikh
Niket Parikh 2020 年 6 月 18 日
Ah okay. Thank you madhan and Rik.

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

その他の回答 (0 件)

カテゴリ

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

製品

リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by