clear; infile = fopen('sentence13.txt', 'r'); sent = fscanf(infile, '%c', inf); fclose(infile); code = isstrprop(sent, 'alpha'); n = length(code); w = 1; ch = 0; for i = 1:n if code(i) == 1 ch = ch + 1; A(w,ch) = sent(i); else w = w+1; ch = 0; end end [w let] = size(A); outfile = fopen('sentence13.out', 'w'); for i = w : -1 : 1 for j = 1:let ch = A(i,j); if isstrprop(ch, 'alpha') fprintf(outfile, '%s', ch); else if i > 1 fprintf(outfile, '%s', blanks(1)); end break; end if j == let fprintf(outfile, '%s', blanks(1)); end end end fprintf(outfile, '%s', '.'); fclose(outfile);