function A = rdskyline(pathname) A = []; % open specified input file fid = fopen(pathname, 'r'); if (fid == -1) return end % read size of matrix (table) num = fread(fid, 1, 'double'); if (num <= 0) status = fclose(fid); return end A = zeros(num, num); % loop over all columns j for j = 1:num [pos nread] = fread(fid, 2, 'double'); if (nread ~= 2) status = fclose(fid); return end first = pos(1); last = pos(2); % read if valid indices if (first > 0 && last >= first) count = last-first+1; [A(first:last,j) nread] = fread(fid, count, 'double'); if (nread ~= count) status = fclose(fid); return end end end status = fclose(fid); end