Loading cell array data from a .dat file reformatting data into doubles?
1 view (last 30 days)
Show older comments
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/225659/image.png)
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/225780/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/225780/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/225662/image.png)
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)
See Also
Categories
Find more on Software Development Tools in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!