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.

 采纳的回答

clear tf

4 个评论

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?
You by mistake named a variable tf , so you see how much of a pain it gives ya ;)
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

请先登录,再进行评论。

更多回答(0 个)

类别

在 帮助中心 和 File Exchange 中查找有关 Programming 的更多信息

产品

版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by