Article View: comp.soft-sys.matlab
Article #162Re: help: formatting matlab vectors/columns with fprintf
From: Cleve Moler
Date: Thu, 01 Sep 1994 19:34
Date: Thu, 01 Sep 1994 19:34
35 lines
1740 bytes
1740 bytes
In article <344ofl$970@news.duke.edu>,
Rob Thieler <rthieler@rogue.geo.duke.edu> wrote:
>Greetings. I've got a little problem in matlab 4.1.1 that's driving me
>nuts. ...
>
>The commands I've been using are:
>
>fid = fopen('L12_030794_bathy_corr.dat','w');
>
>fprintf(fid,'%.6f\t%.6f\t%.1f\t%02.0f\t%02.0f\t%02.0f\t%06.4f\t%.8f\t%.1
>f\n', L12_030794_bathy_corr);
>
>Rob Thieler
Hi
I think all you need to add is one apostrophe to transpose your matrix:
fprintf(fid,'%.6f\t... \n', L12...corr');
^-- that's it, there.
When you say
fprintf(fid,'format',A)
the matrix A is sent to the print routine column by column, just
like A(:). The format is used over and over again until all the data
has been processed. Since you are thinking of the format as
describing a row, not a column, use
fprintf(fid,'format',A')
Hope this is what you were after.
-- Cleve Moler
Technical Details
Message-ID:
<345abk$si6@acoma.mathworks.com>Path:
arc1-ca.pugleaf.net!bga.com!news.sprintlink.net!uunet!MathWorks.Com!not-for-mailReferences:
<344ofl$970@news.duke.edu>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11b9ee,3464ae9319a8cca9 X-Google-Attributes: gid11b9ee,public X-Google-Thread: 106e3f,3464ae9319a8cca9 X-Google-Attributes: gid106e3f,public X-Google-Thread: 114e5f,3464ae9319a8cca9 X-Google-Attributes: gid114e5f,public X-Google-ArrivalTime: 1994-09-01 20:44:10 PST Path: arc1-ca.pugleaf.net!bga.com!news.sprintlink.net!uunet!MathWorks.Com!not-for-mail From: moler@mathworks.com (Cleve Moler) Newsgroups: comp.soft-sys.matlab,duke.general,duke.math Subject: Re: help: formatting matlab vectors/columns with fprintf Date: 1 Sep 1994 15:34:12 -0400 Organization: The MathWorks, Inc., Natick, MA 01760 Lines: 36 Message-ID: <345abk$si6@acoma.mathworks.com> References: <344ofl$970@news.duke.edu> NNTP-Posting-Host: acoma.mathworks.com