Path: news.mathworks.com!not-for-mail
From: "maxroucool mvjz" <maxroucool@yahoo.fr>
Newsgroups: comp.soft-sys.matlab
Subject: Test the existence of a variable
Date: Wed, 4 Nov 2009 21:40:23 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 32
Message-ID: <hcssc7$3rq$1@fred.mathworks.com>
Reply-To: "maxroucool mvjz" <maxroucool@yahoo.fr>
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 1257370823 3962 172.30.248.37 (4 Nov 2009 21:40:23 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 4 Nov 2009 21:40:23 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2077384
Xref: news.mathworks.com comp.soft-sys.matlab:582528


Hi all,

I have a really basic problem, but I don't find any solution...
I am doing a function in which you can put 2 arguments 'files' and 'options', but 'options' is not compulsory.
So I want to test its existence, and if the user didn't set any options, so I have to give the default value to 'options'.
Here is my code:

[code]
if exist(options,'var') && strcmp(options.denoised.state, 1)
    if ~isfield(options.denoised,'threshold')
        options.denoised.threshold = 'heursure';
    end
    if ~isfield(options.denoised,'wname')
        options.denoised.wname = 'sym8';
    end
    if ~isfield(options.denoised,'level')
        options.denoised.level = 5;
    end
else
    options.denoised.state = 0;                 % Bool: Denoise signal or not?
    options.denoised.threshold = 'heursure';    % Can be: rigrsure, heursure, sqtwolog, minimaxi
    options.denoised.wname = 'sym8';            % Many different names: see wfilters()
    options.denoised.level = 5;                 % Level
end
[/code]

But when I run it, Matlab says me: "??? Undefined function or variable 'options'." !!!
That's wired, isn't it ?!?


Thank you for you help!
+++