MATLAB Answers

Loading cell array data from a .dat file reformatting data into doubles?

13 views (last 30 days)
Justin Sung
Justin Sung on 20 Jun 2019
Commented: Justin Sung on 20 Jun 2019
hi all,
Basically, my problem is that I have a 2D cell array full of data that has a mixture of numbers and strings that contain numbers. I saved this huge cell array into a .dat file so that I could reference it later. When I try to load the data in, Matlab auto formats it into a double matrix and I lose my information contained in the strings. Within my cell array, I have data in the for of 0 and x_y, where the x and y can be any real number. I can't describe it clearly, so I've attatched a few pictures of the behavior.
My .data file looks like this:
I ran this quick few lines to import the data:
[filename, directory_name] = uigetfile('*.dat', 'filename.dat');
fullname = fullfile(directory_name, filename);
data = load(fullname);
This saves the data into the variable . However, when I open to take a look, matlab has optimized(?) the strings into doubles, essentially taking only the first occuring number and the data seen here:
2_3 becomes just 2 and etc.
I was wondering I there was a special load function that would preserve my strings instead of formatting them into doubles. It seems like an easy fix to go in manually, but I really want to save this as a last resort since the matrix is well over 1000x1000 in size ...
Thanks in advance

Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by