readTensileData.m
function [L, d, DLMat, FMat] = readTensileData(filename)
% read tensile test data from file
% parameter
% filename file with test data
% returns
% L specimen length [mm]
% d specimen diameter [mm]
% DLMat elongation [mm]
% FMat applied force [kN]
fid = fopen(filename,"r");
% read header
data = textscan(fid,"%f", 2, "CommentStyle", "#");
L = data{1}(1); % in mm
d = data{1}(2); % in mm
% read data sets
I = 0;
while ~feof(fid)
data1 = textscan(fid,"%f %f", "EmptyValue", NaN); % read data til comment
I = I + 1;
len(I) = size(data1{1},1); % collect data sizes
DL{I} = data1{1}; % in mm
F{I} = data1{2}; % in kN
fgetl(fid); % read next comment
end
% prepare matrices for all datasets, fill with NaN's
N = max(len); % maximal data size
nSets = length(len); % number of data sets
DLMat = NaN(N, nSets);
FMat = NaN(N, nSets);
% insert data columns in matrices
for I=1:nSets
DLMat(1:size(DL{I},1), I) = DL{I};
FMat(1:size(F{I},1), I) = F{I};
end
fclose(fid);