how can i fix this error "Array indices must be positive integers or logical values"?
Show older comments
knowing that z2 is a function that determines the angles, vq2 are velocities determined with interpolation, d are reference angles and vel_thr are fixed speeds in the following for loop this error is thrown " Array indices must be positive integers or logical values".
x = [0 157 670 1255]; %distance
v = [0 7 30 70]; %velocity
xq = z1; %distance
vq2 = interp1(x,v,xq,'linear');
d= [-161.42 -125.58 -89.74 -53.91 -18.07 17.76 53.59 89.43 125.27 161.11];
vel_thr= [5 6 15 25 30 35 45 55 60 70];
for i=1:length(z2);
angsel=z2(i)*180/pi;
[tmp1 icol1]=min(abs(angsel-d));
[tmp2 icol2]=min(abs(360+angsel-d));
if tmp1<tmp2
icol(i)=icol1;
else
icol(i)=icol2;
end
velsel=vq2(i);
itmp=find(velsel>=vel_thr);
irow(i)=itmp(end);
prob(i)=CF20(10+irow(i),1+icol(i));
end
CF20 is a 20x11 matrix of numbers all greater than or equal to zero. i tried to insert these values both with an excel file and with a txt file, but in both cases it doesn't work.
how can I solve this problem?
Accepted Answer
More Answers (1)
Tewachew
on 17 Mar 2024
0 votes
Array indices must be positive integers or logical values.
Error in load_flow8 (line 15)
Pg(round(DG(n + Num_DG),0)) = Pg(round(DG(n + Num_DG),0)) + Ps;
what is the error of this code????
1 Comment
Image Analyst
on 17 Mar 2024
@Tewachew see the FAQ:
for a thorough explanation.
Categories
Find more on Logical 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!