Cant load large data set

2 次查看(过去 30 天)
zachary slawek
zachary slawek 2021-10-19
I am trying to load a large data text file but I cant seem to get matlab to load it. I am trying : load Kenfrench4.txt; : when i try the command i get this error message:
Error using load
Unable to read file '49KenFrench2.txt'. Input must be a MAT-file or
an ASCII file containing numeric data with same number of columns in
each row.
I attached the file and I would like to know what is wrong with the file and how i can fix it, the rest of my class seemed to have no problem. Thank you for your time.

回答(1 个)

Image Analyst
Image Analyst 2021-10-20
That's actually quite a small data set - maybe you only included the first 5000 rows. Anyway you can read it into a matrix or a table. I show both ways.
% Option 1 : Read it into a table.
t = readtable('Kenfrench4.txt', 'Range','A12',...
'ReadVariableNames',true);
% Option 2 : Read it into a double
data = readmatrix('Kenfrench4.txt');
% Get rid of nan rows
goodRows = ~isnan(data(:, 1));
data = data(goodRows, :);

类别

Help CenterFile Exchange 中查找有关 Workspace Variables and MAT-Files 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by