Effacer les filtres
Effacer les filtres

Cant load large data set

2 vues (au cours des 30 derniers jours)
zachary slawek
zachary slawek le 19 Oct 2021
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.

Réponses (1)

Image Analyst
Image Analyst le 20 Oct 2021
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, :);

Catégories

En savoir plus sur Workspace Variables and MAT-Files dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by