Path: news.mathworks.com!not-for-mail From: <HIDDEN> Newsgroups: comp.soft-sys.matlab Subject: Reading in matrix (non-structured) with fscanf-empty input? Date: Sat, 7 Sep 2013 19:42:09 +0000 (UTC) Organization: The MathWorks, Inc. Lines: 29 Message-ID: <l0fvih$rj2$1@newscl01ah.mathworks.com> Reply-To: <HIDDEN> NNTP-Posting-Host: rubyext-04-ls.mathworks.com Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: newscl01ah.mathworks.com 1378582929 28258 172.20.102.180 (7 Sep 2013 19:42:09 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Sat, 7 Sep 2013 19:42:09 +0000 (UTC) X-Newsreader: MATLAB Central Newsreader 3536503 Xref: news.mathworks.com comp.soft-sys.matlab:802058 Hello, I have written output (numeric only) to a text file as follows: fmt2=['%8s' '%4.f%4.f%8d%8d%8d%8d%8d%8d%8d%8d%8d%8d%8d%8d%8d%8d%8d\n']; sav_fid2 = fopen('Names2.txt', 'wt'); for jkl = 1:cnf fprintf(sav_fid2,fmt2, 'stage_1.txt', xy(jkl,:),sum(data(ROI1,jkl+1)),sum(data(ROI2,jkl+1)),sum(data(ROI3,jkl+1)),sum(data(ROI4,jkl+1)),sum(data(ROI5,jkl+1)),sum(data(ROI6,jkl+1)),sum(data(ROI7,jkl+1)),sum(data(ROI8,jkl+1)),sum(data(ROI9,jkl+1)),sum(data(ROI10,jkl+1)),sum(data(ROI11,jkl+1)),sum(data(ROI12,jkl+1)),sum(data(ROI13,jkl+1)),sum(data(ROI14,jkl+1)),sum(data(1:end,jkl+1))); end fclose(sav_fid2); Now, I need to read in those numbers (as a matrix), multiply them by 256 and then print the matrix (after multiplication) to a different text file. I tried this: clear clc fmt2=['%8s' '%4.f%4.f%8d%8d%8d%8d%8d%8d%8d%8d%8d%8d%8d%8d%8d%8d%8d\n']; fid = fopen(''stage_1.txt'', 'wt'); num_t = fscanf(fid, fmt2); fclose(fid); I am getting: num_t = '' Is there a mistake with the format used to read the pattern with fscanf? Is fscanf the most appropriate way to read in these numbers? * the number 256 will change from file to file. I can handle that part of the code. For the purposes of this example, we can assume that 256 is a constant.