Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
fread

Subject: fread

From: Elnaz

Date: 10 May, 2013 19:07:07

Message: 1 of 2

Hi all,
I'm trying to read a .dat file. When I directly import the file into workspace it geneartes a vector of all the data in the file. I want to read it into a matrix as it appears in the .dat file. If I use fid = fopen('filename'); A =fread(fid,[m n]); the data in A is something else! Why?

Thanks,
Elnaz

Subject: fread

From: Elnaz

Date: 10 May, 2013 19:19:06

Message: 2 of 2

"Elnaz " <ebsadeghian@gmail.com> wrote in message <kmjggr$n85$1@newscl01ah.mathworks.com>...
> Hi all,
> I'm trying to read a .dat file. When I directly import the file into workspace it geneartes a vector of all the data in the file. I want to read it into a matrix as it appears in the .dat file. If I use fid = fopen('filename'); A =fread(fid,[m n]); the data in A is something else! Why?
>
> Thanks,
> Elnaz
Let me add that there are a few lines of header text in the .dat file like this:
504
252
7
1 85 170 256 339 426 0
2 86 171 257 340 427 0
3 87 172 250 341 428 0
4 88 173 258 342 429 0
...
The first three lines are headers.
How should I read this by fread?

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us