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.

 Akzeptierte Antwort

madhan ravi
madhan ravi am 18 Jun. 2020
clear tf

4 Kommentare

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
Ah okay. Thank you madhan and Rik.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Programming finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by