I want to plot the step response of a transfer function but when I use step() i get an error message. I have tried to paste example-code from the matlab help but I still get error.
This is the example code:
(https://se.mathworks.com/help/control/ref/lti.step.html#d122e120846)
sys = tf(4,[1 2 10]);
step(sys)
The message I get is:
"Unable to use a value of type tf as an index."
Anyone who knows what might be wrong?

1 comentario

Jon
Jon el 25 de Sept. de 2020
I can't reproduce the problem running R2020a Update 3. I get a nice step response plot with those same two commands.
I assume you have tried clearing the workspace first, or reopening MATLAB completely just to make sure that there isn't some other variable assignment confusing things, and then, just type those two lines of code

Iniciar sesión para comentar.

 Respuesta aceptada

Star Strider
Star Strider el 25 de Sept. de 2020
I strongly suspect that you have a variable named ‘step’.
Run this is a script or your Command Window:
which step -all
I suspect the first line will be:
step is a variable.
If so, rename the variable to something else that is relevant to the context.

3 comentarios

Fangjun Jiang
Fangjun Jiang el 25 de Sept. de 2020
Editada: Fangjun Jiang el 25 de Sept. de 2020
make sense
>> step=1:12
step =
1 2 3 4 5 6 7 8 9 10 11 12
>> step(sys)
Unable to use a value of type tf as an index.
Marcus Carlsson
Marcus Carlsson el 25 de Sept. de 2020
Hi!
You were right, thank you very much!
Star Strider
Star Strider el 25 de Sept. de 2020
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (1)

Fangjun Jiang
Fangjun Jiang el 25 de Sept. de 2020

0 votos

tf() is supposed to define a Transfer Function. You might have a variable called "tf" or other function called "tf". Do the following and see what are the returns
tf
which -all tf

Categorías

Más información sobre MATLAB en Centro de ayuda y File Exchange.

Productos

Versión

R2019b

Preguntada:

el 25 de Sept. de 2020

Comentada:

el 25 de Sept. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by