Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Matlab: Using the exist function within a structure

  1. Aug 24, 2011 #1
    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;



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

  2. jcsd
  3. Feb 1, 2012 #2
    try this:

    X = isfield(team,'city')
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook