PDA

View Full Version : Matlab: Using the exist function within a structure


craigpmorgan
Aug24-11, 04:31 AM
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

rpach
Feb1-12, 10:33 AM
try this:

X = isfield(team,'city')