how to solve this error "subscripts must be indices or real positive integers' in this code..how to solve this?
1 view (last 30 days)
Show older comments
for k=1:201;
ct = ctmin+cstep*(k-1);
lt = (1/ct)*(((2*td)/pi)^2);
for i=1:101;
n = nmin+nstep*(i-1);
icr = (sqrt(ct)*vdc)/(sqrt(lt));
doeffmax = domax/(1+((4*lt*fs)/(n^2*ro)));
if(doeffmax > ((n*vo)/vdc))
if (((io/n)<ippkmax)&(icr<(iocrmax/n)))
n=n+1;
lres(n)= lt;
cres(n)= ct;
nres(n)= n;
iocr(n)= n*icr;
ippk(n)= io/n;
end
end
end
end
1 Comment
Walter Roberson
on 15 Nov 2015
Please show the complete error message, everything in red.
Also, what are the values of nmin and nstep?
Answers (1)
Image Analyst
on 15 Nov 2015
See the FAQ: http://matlab.wikia.com/wiki/FAQ#How_do_I_fix_the_error_.22Subscript_indices_must_either_be_real_positive_integers_or_logicals..22.3F which explains it pretty well. Just a quick scan and I see n = nmin+nstep*(i-1); and later n being used as an index. So on the first iteration n=nmin, and if nmin = 0 then it will throw that error.
0 Comments
See Also
Categories
Find more on Introduction to Installation and Licensing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!