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?

 采纳的回答

Azzi Abdelmalek
Azzi Abdelmalek 2014-11-27
编辑:Azzi Abdelmalek 2014-11-27
Use fread to read binary files

3 个评论

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

请先登录,再进行评论。

更多回答(1 个)

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?

类别

帮助中心File Exchange 中查找有关 Large Files and Big Data 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by