I am trying a script that does not work. First I define a structure in matlab:
item_no: 123cost: 19.9900price: 39.9500code: 'g'
then I have made a script who will try to find out the value of a field in the structure:
inputfield=input('Which field would you like to see: ','s')if isfield(package, inputfield)fprintf('The value of the %s field is: %c\n',inputfield,...eval(['package.'inputfield]))elsefprintf('Error: %s is not valid field\n', inputfield)end
but i get error message:
>> structurevalue ??? Error: File: structurevalue.m Line: 6 Column: 22 Unexpected MATLAB expression.