Path: news.mathworks.com!newsfeed.mathworks.com!fu-berlin.de!uni-berlin.de!not-for-mail
From: Waldemar Krzok <waldemar.krzok@ukbf.fu-berlin.de>
Newsgroups: comp.soft-sys.matlab
Subject: Re: writing to a text file
Date: Wed, 06 Oct 2004 17:32:46 +0200
Organization: Freie Universitaet Berlin
Lines: 33
Message-ID: <4164101E.4040004@ukbf.fu-berlin.de>
References: <eeec35e.-1@webx.raydaftYaTP>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de /hccFPLNYqeVhsLA5faPNA7e02m8WWmW+gJzEitmQw/FoqnaPApLqj
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de-DE; rv:1.0.1) Gecko/20020823 Netscape/7.0
X-Accept-Language: de-de, de
Xref: news.mathworks.com comp.soft-sys.matlab:233502





Alan Wilkes wrote:
> Hi,
> I'm faced with a queer problem..
> 
> test is a m X 2 matrix that contains something like this :
> 
> 511 0
> 389 375
> 389 379
> 385 362
> ...
> 
> fid = fopen('test.txt','w');
> fprintf(fid,'%d %d\n',test);
> fclose(fid);
> 
> But, when I write it to a file, and read it as "type test.txt" as
> above.. the matrix is messed up as,
> 511 389
> 389 385 ( these r the first column elements in the matrix "test" )
> ....
> 
> It's puzzling why it displays column-major-wise, plus it drops the
> zero (0) in row 1 & Can somebody give me the solution to this weird
> problem.. ?

try this
fprintf(fid,'%d %d\n',test');

Waldemar