Path: news.mathworks.com!not-for-mail
From: "helper " <spamless@nospam.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: problem saving matlab workspace
Date: Tue, 13 May 2008 05:20:19 +0000 (UTC)
Organization: Timothy S. Farajian, Inc.
Lines: 44
Message-ID: <g0b8ej$41t$1@fred.mathworks.com>
References: <g0b713$5fp$1@fred.mathworks.com>
Reply-To: "helper " <spamless@nospam.com>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1210656019 4157 172.30.248.37 (13 May 2008 05:20:19 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 13 May 2008 05:20:19 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1272923
Xref: news.mathworks.com comp.soft-sys.matlab:468057


"Anup " <anupekbote@gmail.com> wrote in message <g0b713
$5fp$1@fred.mathworks.com>...
> I'm using matlab7.0.
> The code tries to learn a particular game.
> So the game is played several thousand times.
> So it would take hours/days to complete the simulation.
> Becuase of the regular power cuts i usually resort to 
> saving the work space at the end of each game using 
> save('filename').
> 
> Intilaly i did not face any problems with this.even 
though 
> the number of games played were as large as 10,000. But 
> ocassionally i had an error saying that unable to save in 
> the specified file. But it used to work if i either 
> restarted the game or changed the filename.
> 
> But now the error is now more persistent. Almost every 
> time the same error pops up and this usally happens 
around 
> the 1200th game or 3000th game.Can someone help me out 
> with this problem.


I'm not sure what is causing your error, however you could 
try wrapping the SAVE command in a try/catch and repeating 
until the save is successful.

errorOccurred = true;
while errorOccurred
  try
    errorOccurred = false;
    save(...)
  catch
    errorOccurred = true;
    % Maybe put a pause or drawnow
    % or even changing the filename here
  end
end

Also, within the CATCH, you might want to verify (using the 
LASTERROR command) that the error that occurred is actually 
the one you want to ignore.