how to display a dat file in matlab

4 views (last 30 days)
varsha
varsha on 5 May 2014
Commented: Geoff Hayes on 5 May 2014
I want to display a *.dat file using matlab. When I tried with the following code, I'm getting error like cell array mismatch and sometimes I won't get any error but the cell array will be empty.
My code is:
fid = fopen('somefile.dat','r');
datacell = textscan(fid, '%f%f%f', 'HeaderLines', 1, 'Collect', 1);
fclose(fid);
A.data = datacell{1};
Any suggestions are welcome!
  1 Comment
Geoff Hayes
Geoff Hayes on 5 May 2014
Can you post an example (with code and data) that results in the cell array mismatch error?
As for the cell array being empty, that could indicate a problem with your format string or with (some of) the data within your file not matching the format string. According to the documentation on this command (see textscan), When textscan reads a file or string, it attempts to match the data to the formatSpec string. If textscan fails to match a data field, it stops reading and returns all fields read before the failure.
By the way, is the Collect option valid? Or should it read CollectOutput instead?

Sign in to comment.

Answers (0)

Categories

Find more on Large Files and Big Data in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!