I have the following code working, but I like Matlab's cool indexing syntax so much  and I wouldn't mind if my code ran faster and could show off to my professor and fellow students  that I want to make it work the Matlab array indexing way. You know, where you don't have to use loops to loop through a whole array. So how could I rewrite this loop in a more Matlab style:
for ii=1:throws
if sign(darts(ii,2))==sign(darts(ii,3)) && abs(darts(ii,2))<=abs(darts(ii,3))
darts(ii,4)=sign(darts(ii,3));
end
end
hits=sum(darts(:,4))
Basically, I need to do two comparisons of the cells in column 2 and 3. If I had to only compare the values of column 2 to column three, I could easily do this:
darts(ii,4)=darts(ii,2)<=arts(ii,3);
Ditto if I only had to compare the signs:
darts(ii,4)=sign(darts(ii,2))==sign(darts(ii,3));
But I have to see if column 2 is the same sign as and smaller magnitude than column 3 (if column 2 is between the curve's yvalue, in column 3, and the xaxis).
Math note not necessary to help with the code: this is a student simulation of Monte Carlo integrating: the curve's yvalue is stored in column 3 and the random points are stored in column 2. I compare the points in column 2 to the value of the curve. The number of points below the curve, divided by the number of random points (darts) "thrown" times the total area of the box surrounding the domain and range, gives the area under the curve over the domain (got that!). But to compensate for when the curve is below the xaxis, I have to really find when the random point is between the curve and 0  and that's what I'm trying to do.
P.S. I thought of the following while typing up this post. It seems less kludgey and uses no loops, but actually ran slower! What do you experts think?
darts(:,4)=sign(darts(:,2))==sign(darts(:,3));
darts(:,5)=abs(darts(:,2))<=abs(darts(:,3));
darts(:,6)=(darts(:,4) & darts(:,5)) .* sign(darts(:,3));
hits1=sum(darts(:,6));
Regards,
Jeff
