Saving my .txt file as a .mat file to use it as data for my script.

1 view (last 30 days)
I'm having trouble with saving my .txt file into a .mat file. Can someone help??
This is what I got so far:
Script:
DataEnschede= dlmread('etmgeg_290.txt');
save('etmgeg_290.txt', 'DataEnschede');
error:
Mismatch between file and format character vector.
Trouble reading 'Numeric' field from file (row number 1, field number 1) ==> BRON: KONINKLIJK
NEDERLANDS METEOROLOGISCH INSTITUUT (KNMI)\n
Error in Enschede (line 1)
DataEnschede= dlmread('etmgeg_290.txt');
  2 Comments
Drishti Jain
Drishti Jain on 5 Jun 2020
'dlmread' expects numeric data. Try using 'textscan' or 'readtable' instead.
Walter Roberson
Walter Roberson on 5 Jun 2020
In R2020a, readtable() does a good job reading the contents (provided you do not want any of the header information.)

Sign in to comment.

Accepted Answer

Ameer Hamza
Ameer Hamza on 5 Jun 2020
Try these two options
DataEnschede = readmatrix('etmgeg_290.txt', 'NumHeaderLines', 49);
save('etmgeg_290.mat', 'DataEnschede');
or
DataEnschede = readtable('etmgeg_290.txt', 'NumHeaderLines', 47);
save('etmgeg_290.mat', 'DataEnschede');

More Answers (0)

Community Treasure Hunt

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

Start Hunting!