How can I open a binary .dat file using matlab?

Hello everyone,
I am using a handheld radio-frequency spectrum analyzer to save a trace of spectrum. The problem is that the files I saved have a .dat format and really do not know how to read it in matlab. I tried openning it using a conventional text reader like word, notepad and wordpad but I saw only symbols in the file. . I tried:
fid = fopen('C:file.dat','r');
B = textscan(fid, '%f', 'HeaderLines',2);
B = B{1};
fclose(fid);
. but My answer for B is empty. I do not know what to do anymore, can you help me guyz?

 Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 27 Nov. 2014
Bearbeitet: Azzi Abdelmalek am 27 Nov. 2014

0 Stimmen

Use fread to read binary files

3 Kommentare

Kaio
Kaio am 27 Nov. 2014
Could you please give me a example of a code that reads a .DAT file called test and plot the values of this file as it forms a waveform of the frequency spectrum? I have tried but it eid not work.
Attach your dat file
Kaio
Kaio am 28 Nov. 2014
Sorry for the delay, I was about to sleep, here in Brazil it is a different time zone. :)
I am attaching the .dat compressed in .rar file because I couldn't upload the .dat file itself. Thanks a lot.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Kaio
Kaio am 28 Nov. 2014

0 Stimmen

Let me tell you guyz what I am trying to do.
I am following Azzi's advice and trying to use fread. the syntax is more like that
fileId = fopen('filename.dat');
A = fread(fileId);
The problem is that I am receiving -1 as a answer for fopen and when I try using fread with fileId I get a message that says: "Invalid file identifier. Use fopen to generate a valid file identifier."
Does anyone know what can I do?

Kategorien

Mehr zu Large Files and Big Data finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 27 Nov. 2014

Beantwortet:

am 28 Nov. 2014

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by