Thread Subject: how to check if a parameter is already in workspace

Subject: how to check if a parameter is already in workspace

From: Serkan

Date: 29 Jun, 2009 22:51:01

Message: 1 of 7

hello

for my m-script i need to check if a parameter is already in workspace.
there was something like isvar(parameter) or like that which gives boolean 1 for yes and 0 for no..
thanks for any help
serkan ozturk

Subject: how to check if a parameter is already in workspace

From: Husam Aldahiyat

Date: 29 Jun, 2009 23:07:01

Message: 2 of 7

Use exist().

Subject: how to check if a parameter is already in workspace

From: Serkan

Date: 30 Jun, 2009 17:42:01

Message: 3 of 7

Hi
how can i use "exist" in the M-Function of my GUI

        case 'PB_STARTSIM'
            Check = evalin('base',(char(exist('Uk','var'))));
            if Check == 1;
                open model;
                evalin('base','sim model');
            else
                errordlg('Please load the parameters at first','Error');
            end

I have in the GUI a start simulation button. Before starting the simulation though i need to check if Uk is already in Workspace. If so 'model.mdl' will be opened and simulation will be started. But it doesnt work somehow.
if you can help i would very appreciate
greetings
serkan ozturk

Subject: how to check if a parameter is already in workspace

From: us

Date: 30 Jun, 2009 17:50:16

Message: 4 of 7

"Serkan " <serkanvai@gmail.com> wrote in message <h2dip9$hh5$1@fred.mathworks.com>...
> Hi
> how can i use "exist" in the M-Function of my GUI
>
> case 'PB_STARTSIM'
> Check = evalin('base',(char(exist('Uk','var'))));

should read

     res=evalin('base','exist(''Uk'',''var'');');

us

Subject: how to check if a parameter is already in workspace

From: Husam Aldahiyat

Date: 30 Jun, 2009 17:52:01

Message: 5 of 7

"Serkan " <serkanvai@gmail.com> wrote in message <h2dip9$hh5$1@fred.mathworks.com>...
> Hi
> how can i use "exist" in the M-Function of my GUI
>
> case 'PB_STARTSIM'
> Check = evalin('base',(char(exist('Uk','var'))));
> if Check == 1;
> open model;
> evalin('base','sim model');
> else
> errordlg('Please load the parameters at first','Error');
> end
>
> I have in the GUI a start simulation button. Before starting the simulation though i need to check if Uk is already in Workspace. If so 'model.mdl' will be opened and simulation will be started. But it doesnt work somehow.
> if you can help i would very appreciate
> greetings
> serkan ozturk

if exist('n','var')
    (do stuff)
else
~
end

Subject: how to check if a parameter is already in workspace

From: Matt Fig

Date: 30 Jun, 2009 18:04:02

Message: 6 of 7

Wouldn't it be easier, safer, and more in keeping with standard practice to have the user either:

1. pass Uk as the GUI is started.
2. Have the button open a load dialog box for the user to specify which parameter file(s) to use.


Just a thought.

Subject: how to check if a parameter is already in workspace

From: varun dj

Date: 27 Oct, 2009 05:57:01

Message: 7 of 7

Hi
I have two S-Function blocks(S1 and S2) which accepts one parameter each.
How to check whether S1 and S2 both contains same parameter value?
(I mean, if S1 has parameter value "1", I need to restrct S2 parameter value taking "1")

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
evalin us 30 Jun, 2009 13:54:03
code us 30 Jun, 2009 13:54:03
syntax us 30 Jun, 2009 13:54:03
exist Serkan 30 Jun, 2009 13:44:09
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com