function [FileName, Strain, Modulus, Strain2, Damping, Selection] = MatRead(GUILOCATION)
%MATREAD Summary of this function goes here
%   Detailed explanation goes here

[FileName PathName] = uigetfile('.txt', 'Select File',...
    [GUILOCATION,'\Material']);

if PathName == 0
    return
end

% Read Selected material values
a = textread([PathName, FileName], '%s'); %#ok<RE%#ok<*MSNU> MFF1>

count = str2num(strcat(cell2mat(a(2))));

if isempty(count)
    errordlg('Invalid format for material.')
    return
end

Strain = zeros(count,1);
Modulus = zeros(count,1);

% Assign values to appropriate vectors
try
    for i = 1:count
        Strain(i) = str2num(cell2mat(a(2*i+3)));
        Modulus(i) = str2num(cell2mat(a(2*i+4)));
    end
    
    count2 = str2num(strcat(cell2mat(a(6+count*2))));
    Strain2 = zeros(count2,1);
    Damping = zeros(count2,1);
    for i = 1:count2
        Strain2(i) = str2num(cell2mat(a(2*i+7+count*2)));
        Damping(i) = str2num(cell2mat(a(2*i+8+count*2)));
    end
    
    FileName = strrep(FileName, '.txt', '');
    Strain = Strain';
    Modulus = Modulus';
    Strain2 = Strain2';
    Damping = Damping';
    
    StrainOri = Strain;
    ModulusOri = Modulus;
    Strain2Ori = Strain2;
    DampingOri = Damping;
    
    Shear = Strain.*Modulus/100;
    ShearOri = Strain.*Modulus/100;
    ShearStrength = Shear(end);
    Slope = zeros(1, length(Shear));
    
    Selection = 2;
    
catch
    
    errordlg('Invalid format for material.')
    
    Selection = 1;
    return
    
end

end

