I need to plot the Root Locus with a changing "k" of a given transfer function without using any special Matlab functions i.e., "rlocus", "tf". I'm allow to use roots. The code bellow displays an error/warning message (Subscript indices must either be real positive integers or logicals.) that I have not been able to figure out .
See my code.
%In vector form
num = input('Enter the coefficients of numerator of J(s): ');
%In vector form
den = input('Enter the coefficients of denominator of J(s): ');
qs = 0;
for k = 0:0.1:1000;
qs(k,:) = roots(den + num.*k);
end;
plot(qs,'+'), xlabel('\sigma'), ylabel('j\omega'), title ('Root-Locus'), grid
Thank you
qs(k,:)
butq
is not always an integer, you're trying to doq(0,:)=...
,q(0.1,:)=...
, etc. The Matlab error message told you exactly what the problem was. – David