Subscript indices must either be real positive integers or logicals.

I
Ikramullah · Feb 26, 2021 · 2K views
Question
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 PhD Expert
Answered Aug 24, 2026
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

100% Run Guarantee 3-Hour Fast-Track Delivery

Need a Custom Version or Complete Simulation for This Problem?

Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.

Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!