Matlab: Using the exist function within a structure

Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 10K views
craigpmorgan
Messages
8
Reaction score
0
Hi All,

Does anyone if it's possibe to use the 'exist' function in Matlab to check whether any data has been entered into a particular field of a structure. I'd like something like the following, where 'identification' is a user-input variable, 'team' is the structure and 'city' is the field.

identifiaction = input('Enter I.D: ');
X = exist(team(identification).city);

if X == 1;
action

else
action

end

I need this to control where new data is input into the structure. Thanks for your time.

Craig
 
Physics news on Phys.org
try this:

X = isfield(team,'city')