% -----------------------------------------------------
% structures1.m
% -----------------------------------------------------
% Create a structure - engr1234 with the following fields
% lastname - last name of a student
% firstname - first name of a student
% attendance - a boolean variable (1 or 0) indicating 
%           if student is still coming to class or not
% grade - student's grade as a percentage 
% -----------------------------------------------------
% Notes: structure with information on 1 student
% -----------------------------------------------------
% Copyright and license details available at matlabmarina.com
%------------------------------------------------------

clear;
clc;

% building a structure
engr1234.lastname = 'Jones';
engr1234.firstname = 'David';
engr1234.attendance = 1;
engr1234.grade = 90;

% display the students information
disp(engr1234);

% display the lastname
fprintf('the last name of the student is %s\n',engr1234.lastname);

% display the field names of the structure
fldNames = fieldnames(engr1234);
n = length(fldNames);

fprintf('\n\nThe field names : \n');
for k = 1 : 1 : n
    disp(fldNames{k}); %  '{}' requires knowledge of cell arrays
end


