function smat = getsmat(fnm); % function smat = getsmat(fnm); % gets a string matrix from ascii file % fnm is the name of the file % smat is the string matrix % REQUIRES that the matrix have every line EXACTLY the same length % REQUIRES that each line end in ascii 13, ascii 10 (CR LF) % % example: % smat = getsmat('c:\dbases\xyz.dbd'); % copyright, 1996, William F. Sharpe % wfsharpe@leland.stanford.edu % this version Jan. 15, 1996 fid = fopen(fnm,'r'); s = fscanf(fid,'%c'); fclose(fid); locr = findstr(s,setstr(13)); ncols = locr(1) - 1; nrows = length(s)/(ncols+2); ss = reshape(s,ncols+2,nrows); smat = ss'; smat = smat(:,1:ncols);