Subscript indices must either be real positive integers or logicals.

Illustration
Ikramullah - 2021-02-26T11:21:36+00:00
Question: Subscript indices must either be real positive integers or logicals.

Hi i am getting an error in this MATLAB code and im not sure whats wrong with it. %define verialbe lm=0.01; Rm=0.05; Kt=1.2; Kb=4.0; B=0.25; J=10.0;   %coeff of denominator a0=((Rm/Kt)+Kb);   a1=(lm*B+Rm*J)/Kt;   a2=((lm*J)/Kt);   %define numerator and demenator num=[1]; den=[a2 a1 a0];   %define TF Gopen=tf(num,den)   % step(Gopen) The error is coming from line 24 which is Gopen=tf(num,den) so can anyone help me.

Expert Answer

Profile picture of Kshitij Singh Kshitij Singh answered . 2025-11-20

I cannot duplicate the error you are getting.
 
When I run:
 
%define variable 
lm=0.01; Rm=0.05; Kt=1.2; Kb=4.0; B=0.25; J=10.0;

%coeff of denominator 
a0=((Rm/Kt)+Kb);

a1=(lm*B+Rm*J)/Kt;

a2=((lm*J)/Kt);

%define numerator and denominator 
num=[1]; 
den=[a2 a1 a0];

%define TF 
Gopen=tf(num,den)
produces:
 
 
Gopen =

                  1
    ------------------------------
    0.08333 s^2 + 0.4187 s + 4.042

Continuous-time transfer function.

and

 

step(Gopen)

produces:

 

 real positive integers


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!