Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


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

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 ]
Derek Goring

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

On Aug 17, 9:15 am, "Alex " <blue.harvest...@gmail.com> wrote:
> 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')
> A = fopen('new02z.dat');
> A = fopen('new02z.dat','r')
> fid = ('new02z.dat')
> A = fread(fid, [307200,514]);
> A = textread('new02z.dat');
> A = dlmread('new02z.dat',' ');
> A = dlmread('new02z.dat',' ',0,0);
> and the import data wizard.
>
> all either imported a single digit, or returned error messages to which I have not found a solution for.
> I am running 7.11.0 R2010b if that helps.
>
> Thanks,
> Alex


Unless you find out for sure what the format is, you've got no hope.
This " It may be exporting the video as a 307200x514 array" is not
good enough.
And what is "a column of padding"? Is it an extra comma at the front
and end of each line? Or what?

One way to check all this is:
fid =fopen('new02z.dat','rt');
line=fgetl(fid)
This will give you the first line in the file and from that you can
figure out what to do next.

Here's a guess at what you need
frewind(fid); % Need to rewind after fgetl
c=textscan(fid,repmat('%f',514,1),20);
which will read the first 20 lines, assuming the delimiter is space.




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

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.