The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: read in matrix from .dat file
Replies: 3   Last Post: Apr 19, 2013 7:43 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Steven Lord

Posts: 18,038
Registered: 12/7/04
Re: read in matrix from .dat file
Posted: Aug 16, 2011 5:32 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Alex " <> wrote in message
> I have been looking around the newsreader as well as other search engines
> for an answer to a problem I'm having, but haven't had any luck.
> I have a camera that records data as a .sif file, and exports it as a .dat
> file. The video has a resolution of 512x512, is 600 frames in length, and
> the file size is 300MB. It may be exporting the video as a 307200x514
> array (it adds a column of padding to both sides of the array, and stacks
> the frames together as rows ), but I'm not sure as I cant get the file
> open. It should be a space delimited file containing only numbers
> representing intensities on the camera, no text. My question is how to
> read the .dat file into matlab as an array. I have tried:
> A = fread('new02z.dat')

FREAD is documented to accept a file identifier (as returned by FOPEN) not a
file _name_.

> A = fopen('new02z.dat');

This creates a file identifier that you can use with the low-level file I/O
functions like FREAD to retrieve the data. It does NOT retrieve the data

Use this THEN use FSCANF, FREAD, TEXTSCAN, etc. [Actually since your file is
plain text, FREAD doesn't seem like the right tool. Try FSCANF or TEXTSCAN


> all either imported a single digit, or returned error messages to which I
> have not found a solution for.

FYI, the group will find it MUCH easier to help you interpret error messages
if you post the full text of the message as well as the code you executed to
generate the error.

Steve Lord
To contact Technical Support use the Contact Us link on

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.