|
|
I have a what I think is a probably a simple problem, but I'm not
seeing the solution.
I have nested loops that if left to run all the way through would
call a function 10,000,000 times, I would like to reduce that.
The code looks like this:
for dist=.01:.01:50 %Look for planets from .01 AU to 50AU
D=dist*AU;
for mass = .01:.01:20 %Look for pl.up to 20 J Masses
MassPlanet=mass*MassJupiter;
v=planet_detect(MassPlanet,MassStar,D,SolarRadius);
if v>=3
typeOStar=cat1,typeOStar,D/AU,MassPlanet/MassJupiter,v]);
disp('Breaking');
break;
end
end
end
The code currently breaks after meeting the v criteria, because I
know any larger values of mass will also work. However, when dist
changes I want the inner loop to start at the last known mass value
that causes the inner loop to break.
Does anyone have any good ideas about this
|
|