🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.soft-sys.matlab
Article #161

help: formatting matlab vectors/columns with fprintf

#161
From: Rob Thieler
Date: Thu, 01 Sep 1994 14:29
39 lines
2318 bytes
Greetings. I've got a little problem in matlab 4.1.1 that's driving me
nuts. Recourse to the manual and the FAQ hasn't helped.

I have a matrix called L12_030794_bathy_corr. It looks like:

>> size(L12_030794_bathy_corr)

ans =

   864     9

I want to save this as an ascii file called "L12_030794_bathy_corr.dat"
using a printf of the form

'%.6f\t%.6f\t%.1f\t%02.0f\t%02.0f\t%02.0f\t%06.4f\t%.8f\t%.1f\n'

where each %.Xf refers to the desired format of vectors/columns 1-9 in
the matrix.

So far, my attempts have met with spectacular failure. I
get a flat file of the data in the each column formatted according to
each of the nine specs in serial fashion. I must be doing something
dumb here.  I'm assuming that this command would behave like a printf
in C or awk (i.e., print each row using format #1 for $1, #2 for $2,
etc.) but obviously this is not the case. Can someone help me out?

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);

Thanks in advance,

Rob Thieler                               | rthieler@rogue.geo.duke.edu
Duke University, Department of Geology    |         Tel: (919) 681-8228
Pgm for the Study of Developed Shorelines |         Fax: (919) 684-5833
Durham, NC  27708-0228                    |
Technical Details
Message-ID: <344ofl$970@news.duke.edu>
Path: arc1-ca.pugleaf.net!bga.com!news.sprintlink.net!uunet!newsfeed.pitt.edu!godot.cc.duq.edu!news.duke.edu!usenet

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 106e3f,3464ae9319a8cca9,start
X-Google-Attributes: gid106e3f,public
X-Google-Thread: 11b9ee,3464ae9319a8cca9,start
X-Google-Attributes: gid11b9ee,public
X-Google-Thread: 114e5f,3464ae9319a8cca9,start
X-Google-Attributes: gid114e5f,public
X-Google-ArrivalTime: 1994-09-01 14:53:57 PST
Path: arc1-ca.pugleaf.net!bga.com!news.sprintlink.net!uunet!newsfeed.pitt.edu!godot.cc.duq.edu!news.duke.edu!usenet
From: rthieler@rogue.geo.duke.edu (Rob Thieler)
Newsgroups: comp.soft-sys.matlab,duke.general,duke.math
Subject: help: formatting matlab vectors/columns with fprintf
Date: 1 Sep 1994 14:29:09 GMT
Organization: Duke University, Dept. of Geology
Lines: 39
Distribution: world
Message-ID: <344ofl$970@news.duke.edu>
NNTP-Posting-Host: althea.geo.duke.edu
X-Posted-From: InterNews 1.0.1@althea.geo.duke.edu
X-Authenticated: rthieler on POP host rogue.geo.duke.edu