Info
This question is closed. Reopen it to edit or answer.
How to rectify the error - 'Subscript indices must be real positive integers or logicals' for the code below
1 view (last 30 days)
Show older comments
%...My Code T.F=[(68659K)s^2+(68659K*a+243740K)s+243740Ka]/[s^3+(68659K+68743)s^2 +
%(243740K+246675+68659K*a)s + (46120+243740k*a)]
clf;
t=0:0.01:5;
k=0;
for i = 1:49;
K(i)=51-i*1;
for j = 1:40;
a(j)=2.05-j*0.05;
num=[0 68659*K(i) 68659*K(i)*a(j)+243740*K(i) 243740*K(i)*a(j)];
den=[1 68743+68659*K(i) 68659*K(i)*a(j)+243740*K(i)+246675 46120+243740*K(i)*a(j)];
y=step(num,den,t);
m=max(y);
s=501;while y(s)>0.98 & y(s)<1.02;
s=s-1;end;
ts=(s-1)*0.01;
if m<1.10 & m>1.02 & ts<3.0;
k=k+1;
table(k,:)=[K(i) a(j) m ts];
end
end
end
table(k,:)=[K(i) a(j) m ts]
0 Comments
Answers (1)
Walter Roberson
on 15 Apr 2014
Posting the line that the problem is occurring on helps us to track down the problem.
In your code
while y(s)>0.98 & y(s)<1.02;
s=s-1;end;
you will underflow s to 0 if all of the y satisfy that condition.
4 Comments
Walter Roberson
on 16 Apr 2014
What do you want to have happen in that situation? And what values are you expecting "i" and "j" to have after the end of the nested for loop?
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!