1 function matrix = importMatrices(filename)
5 %
# open file and read all lines 6 fid = fopen(filename,
'rt');
7 temp = textscan(fid,
'%s',
'delimiter',
'\n');
12 idxSep = find(cellfun(@isempty, temp));
13 %# separate matrices to different cells
14 temp2 = mat2cell(temp, diff([0; idxSep; numel(temp)]), 1);
16 temp2(1:end-1) = cellfun(@(x) x(1:end-1), temp2(1:end-1),
'UniformOutput',0);
18 %# convert cell arrays to
double 19 out = cell(size(temp2));
20 for k = 1:numel(temp2)
21 out{k} = cellfun(@str2num, temp2{k},
'UniformOutput',0);
23 out = cellfun(@cell2mat, out,
'UniformOutput', 0);
25 matrix = zeros( size(out{1},1), size(out{1},2), length(out)-1);
26 for i = 1:(length(out)-1)
27 matrix(:,:,i) = out{i};