help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Continue ignoring Error


From: William Krekeler
Subject: RE: Continue ignoring Error
Date: Mon, 7 Feb 2011 17:38:58 +0000

You want the lasterror command, combine this code snippet with the prior code 
snippet response.

try
        some_code()
catch 
  errorArray(k).error = lasterror;
end

-----Original Message-----
From: address@hidden [mailto:address@hidden On Behalf Of Søren Hauberg
Sent: Monday, February 07, 2011 8:22 AM
To: aegreen
Cc: address@hidden
Subject: Re: Continue ignoring Error

man, 07 02 2011 kl. 06:09 -0800, skrev aegreen:
> Currently I am running a loop to read in ~400 csv files. Unfortunately at
> the moment the loop will exit whenever it encounters an error (often because
> of an incorrectly saved file) is there a way for Octave to continue despite
> an error, so that I don't have to continually restart my loop? 
> 
> On top of that is it possible for it to record say a value of a variable and
> the error message to a text file when this occurs?

You should be able to do that using a try-catch block. Your code would,
thus, look something like this

        failures = [];
        for k = 1:400
          try
            read_data ();
          catch
            failures (end+1) = k;
          end_try_catch
        endfor

where you should replace 'read_data' with whatever code you actually
want to run.

Søren

_______________________________________________
Help-octave mailing list
address@hidden
https://mailman.cae.wisc.edu/listinfo/help-octave

reply via email to

[Prev in Thread] Current Thread [Next in Thread]