Re: Getting Out of a For Loop

Etienne Grossmann <[email protected]>
Newsgroups gmane.comp.gnu.octave.general
Message-ID <CANEe7PwyCrfo0n6fJyZ4Mvx7ia2XOXaF_nPKJuFi42fb8Fh75Q@mail.gmail.com>
Let's add an example:

for i = 1:100
  esq = rand(1) / 2^i;
  if esq <  1e-10
    printf ('At i=%i, esq=%g. G''bye\n', i, esq);
    break
  end
end

Good luck, Sam!

Etienne


On Sat, Jul 24, 2021 at 2:57 PM Thomas D. Dean <[email protected]>
wrote:

> On 7/24/21 2:47 PM, Samuel Doughty wrote:
> > I need to get out of a FOR loop. I have written a simple IF test that I
> > thought would work, but it does not. It was this, where esq has been
> > previously evaluated:
> >   if esq<1e-10
> >      exitfor
> >    endif
> > What do I need to do differently, please?
> > Thanks,
> > Sam
> >
> >
> help break
>
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.