xxxxxxxxxx
% Create a sample structure
myStruct.Name = 'John';
myStruct.Age = 25;
myStruct.City = 'New York';
% Accessing a field using a string
fieldName = 'Age';
fieldValue = myStruct.(fieldName);
% Display the result
fprintf('%s: %d\n', fieldName, fieldValue);