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

13 visualizzazioni (ultimi 30 giorni)
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?

Risposta accettata

Azzi Abdelmalek
Azzi Abdelmalek il 27 Nov 2014
Modificato: Azzi Abdelmalek il 27 Nov 2014
Use fread to read binary files
  3 Commenti
Kaio
Kaio il 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.

Accedi per commentare.

Più risposte (1)

Kaio
Kaio il 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?

Categorie

Scopri di più su Data Import and Analysis in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by