Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Append a Column into a Text File
Date: Fri, 20 Sep 2013 11:19:06 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 32
Message-ID: <l1hava$9qv$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: rubyext-06-ls.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1379675946 10079 172.20.102.182 (20 Sep 2013 11:19:06 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 20 Sep 2013 11:19:06 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 3543555
Xref: news.mathworks.com comp.soft-sys.matlab:802704

Hi folks,

I'm aware of the ample on-line tips on appending a new columns into an existing text file. However, my text file has the following structure:

Number Number Number Number Number Number Number Number/Number/Number

Basically they're all digits, each row has 8 columns, the first seven columns are one part i.e. one cell if I may say, and the 8th column has three numbers seperated by slashes. For instance, here's an exemplary segment of my text file:

1	1	6	12	4200 6292	0	-1/-1/-1
1	2	6	96	129   6292	0	1/-1/-1

My issue lies when appending the new column next to the 8th columns, it's complaining, but not sure why. Here's my code:

inputfilename = 'deletemenow.txt'
outputfilename = 'output.txt'
fid1 = fopen(inputfilename, 'rt')
fid2 = fopen(outputfilename, 'wt')
while feof(fid1) == 0
   tline = fgetl(fid1)
    nline = [tline, jCP, '\n']
    fprintf(fid2, nline);
end
fclose(fid1)
fclose(fid2)

...and here's the error I'm getting:
??? Error using ==> horzcat
CAT arguments dimensions are not consistent.

My guts feeling tells me this is because the last column has slashes. What do you guys propose?

Ta.