Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!m44g2000hsc.googlegroups.com!not-for-mail
From: Rune Allnor <allnor@tele.ntnu.no>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Writing Binary file to reduce file size
Date: Thu, 24 Jul 2008 00:17:01 -0700 (PDT)
Organization: http://groups.google.com
Lines: 24
Message-ID: <871fd868-d596-4334-9ccb-340c1df99f14@m44g2000hsc.googlegroups.com>
References: <g62e8r$i37$1@fred.mathworks.com> <muy4p6j89c6.fsf@G99-Boettcher.llan.ll.mit.edu> 
NNTP-Posting-Host: 212.17.141.54
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1216883821 830 127.0.0.1 (24 Jul 2008 07:17:01 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Thu, 24 Jul 2008 07:17:01 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: m44g2000hsc.googlegroups.com; posting-host=212.17.141.54; 
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET 
Xref: news.mathworks.com comp.soft-sys.matlab:481428



On 24 Jul, 07:09, "Pete sherer" <t...@abg.com> wrote:
> I think what I want to do is to write a binary file such
> that I can use other programs besides matlab to read the file. =A0
> I just need an example how to write and read it, at least
> from Matlab workspace. =A0Finally I will use other
> applications to read the data file. =A0
> I think this is a common example, but I can't seem to find
> the solution.

The trick is to use FREAD and FWRITE. If you want to read data
from a file known to contain one 100 x 200 array of doubles,
you do something like

fid =3D fopen('myfile.dat');
A=3Dfread(fid,[100,200],'double');
fclose(fid);

and similar when you write bac to file.

Just be aware of somewhat awkward issues with file formats
(rows-first or column-first storage) and binary numerical
formats (big-endian or little-endian formats).

Rune