I am working on a program at work to calculate what a plane could see as it fly's over a target area. As it goes over the area it could follow one of many tracks, around 100 for the normal area size. I have created a large loop to see if the plane can see parts of the area or not but it runs very inefficiently. I have defined the area as a grid 1001x1001
xgrid a variable 1001x1 defining the x-values.
thelines is a variable 2 x 1001 x tracks, where the first row is the y-values at the corresponding x-value for the top line. The second row is the y-values for the bottom line.
Between these two lines is the visible area. If it can be seen it marks the point on seenarea(1001x1001) as a 1. If not its a 0.
for M=1:tracks
for f=1:1001
for i=1:1001
if xgrid(f,1)>thelines(i,1,M) && xgrid(f,1)<thelines(i,2,M);
seenarea(f,i,M)=1; % This indicated the area has been seen
else
seenarea(f,i,M)=0; % This is not seen
end
end
end
fullbestinfo(1,M)={seenarea(:,:,M)}; % This stores the seen area in another cell
if max(seenarea(:,:,M)) < 1 % No area seen, stop
seenarea(:,:,M)=[];
break
end
end
I have identified this point at the bottleneck of my program using the matlab profiler. Any help would be much appreciated. Thanks, Rich