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?

 Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 27 de Nov. de 2014
Editada: Azzi Abdelmalek el 27 de Nov. de 2014

0 votos

Use fread to read binary files

3 comentarios

Kaio
Kaio el 27 de Nov. de 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.
Azzi Abdelmalek
Azzi Abdelmalek el 28 de Nov. de 2014
Attach your dat file
Kaio
Kaio el 28 de Nov. de 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.

Iniciar sesión para comentar.

Más respuestas (1)

Kaio
Kaio el 28 de Nov. de 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?

Categorías

Más información sobre Large Files and Big Data en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 27 de Nov. de 2014

Respondida:

el 28 de Nov. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by