[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: On being Matlab
From: |
Bill Denney |
Subject: |
Re: On being Matlab |
Date: |
Wed, 1 Nov 2006 16:48:53 -0500 (EST) |
On Wed, 1 Nov 2006, Tom Holroyd (NIH/NIMH) [E] wrote:
warning('off', 'MATLAB:divideByZero');
out = sum(tmpin, dim) ./ sum(~isnan(in),dim);
warning('on', 'MATLAB:divideByZero');
I had them off to start with. So setting them on in his code changes
what I want for the rest of the code. This is just an example, one of
several. Is there a way to turn warnings off permanently?
What about patching warning so that it could be called like:
warning('off', 'MATLAB:divideByZero', 'freeze')
and unless it had the freeze option, it would not change the warning.
Really though, your code should be fixed-- no global variables should have
assumed values, and a simple change like:
function oldval = changewarn(newval, id)
oldval = warning('query', id);
warning(newval, id);
endfunction
and then changing your code to:
oldwarn = changewarn('off', 'MATLAB:divideByZero');
out = sum(tmpin, dim) ./ sum(~isnan(in),dim);
warning(oldwarn, 'MATLAB:divideByZero');
would fix this problem (and be the right way to code it for everyone--
both you and the matlab users).
Bill
--
"Now you see that Evil will always triumph, because Good is dumb."
-- Space Balls