# How can I solve problem regarding subscript indices in for loop?

1 view (last 30 days)
Omar Rashell on 16 Oct 2018
Commented: Kevin Chng on 16 Oct 2018
Hello Matlab users,
I get error massage, when I run the program.
Subscript indices must either be real positive integers or logicals.
Error in Test_2017_02_14 (line 82) clipping(end,:) = clipping(end,:)*1/2;
here is my code:
angle = 0:(2*pi/6):2*pi;
radius = [0 690 1390 1990 2490 2890];
/(length(angle)-1);
angle_fine = 0:(2*pi/60):2*pi;
laf = length(angle_fine);
angle_ex = [2/9 1/2 5/6 7/6 3/2 16/9]*pi;
angle_ufine = 0:(2*pi/600):2*pi;
[~,index_a] = intersect(angle_ufine,angle);
angle_e = 0:(2*pi/6):6*pi;
angle_fine_e = 0:(2*pi/600):6*pi;
flow_left = [0.058; 0.0603; 0.080; 0.119; 0.138; 0.124; 0];
flow_right = [0.058; 0.063; 0.079; 0.099; 0.104; 0.096; 0];
flow_fine(:,1:(laf-1)/2) = repmat(FL,1,(laf-1)/2)+(repmat(FR,1,(laf-1)/2)-repmat(FL,1,(laf-1)/2)).*(angle_fine_mat(:,1:(laf-1)/2)/pi);
flow_fine(:,(laf+1)/2:laf) = repmat(FR,1,(laf+1)/2)+(repmat(FL,1,(laf+1)/2)-repmat(FR,1,(laf+1)/2)).*((angle_fine_mat(:,(laf+1)/2:laf)-pi)/pi);
flow_fine = circshift(flow_fine(:,1:end-1),round(laf*(-110)/360),2);
flow_fine = [flow_fine flow_fine(:,1)];
index = 1:(laf-1)/6:laf;
flowXsurf = flow_fine.*surface_fine;
for i = 1:6
clipping = [clipping(:,end-find(angle_fine==pi/6)+1:end-1)...
clipping(:,1:end-find(angle_fine==pi/6)+1)];
if i>1
clipping(1,:) = clipping(1,:)*1/2;
end
if i<6
clipping(end,:) = clipping(end,:)*1/2;
end
clipping(:,index) = clipping(:,index)*1/2;
for j = 1:6
flow(i,j) = sum(sum(clipping(:,index(j):index(j+1))))/surface(i,j);
end
end
flow = [flow flow(:,1)];
Kevin Chng on 16 Oct 2018
great to know this. A([])

Omar Rashell on 16 Oct 2018
Then it works. I got no errr Massage.
Tank you guys for your afford.

R2017b

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!