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?

 Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 27 Nov 2014
Modifié(e) : Azzi Abdelmalek le 27 Nov 2014

0 votes

Use fread to read binary files

3 commentaires

Kaio
Kaio le 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 le 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.

Connectez-vous pour commenter.

Plus de réponses (1)

Kaio
Kaio le 28 Nov 2014
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?

Catégories

En savoir plus sur Large Files and Big Data dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by