Filter löschen
Filter löschen

Cant load large data set

2 Ansichten (letzte 30 Tage)
zachary slawek
zachary slawek am 19 Okt. 2021
Beantwortet: Image Analyst am 20 Okt. 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.

Antworten (1)

Image Analyst
Image Analyst am 20 Okt. 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, :);

Kategorien

Mehr zu Workspace Variables and MAT-Files finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by