class TensileData
    properties
        Material@char = 'carbon steel'; 
        function material = set(obj,material)
            if ~(strcmpi(material,'aluminum') ||... 
                strcmpi(material,'stainless steel') ||... 
                strcmpi(material,'carbon steel'))
                error('Material must be aluminum, stainless steel, or carbon steel')
            end
        end % Material set function     
        SampleNumber = 0;
        Stress@double = [];
        Strain@double = [];
    properties (Stored = false)
        Modulus@double = 0;
        function modulus = get(obj)
            ind = find(obj.Strain > 0); % Find nonzero strain
            modulus = mean(obj.Stress(ind)./obj.Strain(ind)); 
        end % Modulus get function

    methods
        function td = TensileData(material,samplenum,stress,strain)
            construct td
            td.Material = material;
            td.SampleNumber = samplenum;
            td.Stress = stress;
            td.Strain = strain;
        end % TensileData

   methods
        function disp(td)
            fprintf(1,'Material: %s\nSample Number: %g\nModulus: %1.5g\n',...
                td.Material,td.SampleNumber,td.Modulus);
        end % disp

        function plot(td,varargin)
            plot(td.Strain,td.Stress,varargin{:})
            title(['Stress/Strain plot for Sample ',num2str(td.SampleNumber)])
            xlabel('Strain %')
            ylabel('Stress (psi)')
        end % plot

    methods (Access = 'private') % Access by class members only        
        function m = CalcModulus(td)
        % Over-simplified calculation of Elastic Modulus
            ind = find(td.Strain > 0); % Find nonzero strain
            m = mean(td.Stress(ind)./td.Strain(ind)); 
        end % CalcModulus
  end %TensileData class
