Function 'subsindex' is not defined for values of class 'tf'.

13 ビュー (過去 30 日間)
Giacomo Alessandroni
Giacomo Alessandroni 2014 年 2 月 26 日
回答済み: indah octaviyani 2016 年 10 月 30 日
Hi to all.
I have try to write a simple code for step and impulse response of a transfer function.
The code is this:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% BODE PLOT OF SUSPENTIONS TRANSFER FUNCTION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Suspentions Transfer Function
[num, den] = suspension(240, 16e3, 980, 36, 160e3);
% Make Suspentions Transfer Function
G_s = tf(num, den);
% Create a Bode plot with plot handle h
figure('name', 'Bode plot of Suspentions Transfer Function');
h = bodeplot(G_s);
grid;
% Create a plot options handle p
p = getoptions(h);
% Modify frequency units
p.FreqUnits = 'Hz';
% Apply plot options to the Bode plot and render
setoptions(h, p);
clear h p;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% STEP AND IMPULSE RESPONSE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
figure('name', 'Step and Impulse response');
subplot(211);
step(G_s);
grid;
subplot(212);
impulse(G_s);
grid;
And the output of suspension(240, 16e3, 980, 36, 160e3) is:
num = [0.0612 1]
den = [3.375e-06 0.0001057 0.0167 0.0612 1]
The problem is that in the Command Window the code works, but in my program - with no other command, no. The error is when I call 'step' and is:
Error using subsindex
Function 'subsindex' is not defined for values of class 'tf'.
Thank you in advance, Giacomo.

採用された回答

Giacomo Alessandroni
Giacomo Alessandroni 2014 年 2 月 26 日
Thank you Wayne King, but the question is another.
My function was named:
function kinetic(v_min, v_max, step)
so... it was only my fault.
Thanks anyway.
  1 件のコメント
Wayne King
Wayne King 2014 年 2 月 26 日
yes, that is the problem I said, you are passing a variable called step.

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

その他の回答 (2 件)

indah octaviyani
indah octaviyani 2016 年 10 月 30 日
i get an error for my matlab, could you help me too? Error using subsindex Function 'subsindex' is not defined for values of class 'ss'.

Wayne King
Wayne King 2014 年 2 月 26 日
編集済み: Wayne King 2014 年 2 月 26 日
Giacomo, likely in your program you make the mistake of creating a variable called step.
Then you try to index that variable by G_s which is an object of class tf
So note that
G_s = tf(num, den);
step = randn(10,1);
step(G_s)
gives exactly the error you report. Because I make the mistake of shadowing the step() method with a variable called step.

カテゴリ

Help Center および File ExchangeGet Started with Control System Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by