Saving my .txt file as a .mat file to use it as data for my script.
1 view (last 30 days)
Show older comments
Bram van der Horst
on 3 Jun 2020
Answered: Ameer Hamza
on 5 Jun 2020
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
on 5 Jun 2020
'dlmread' expects numeric data. Try using 'textscan' or 'readtable' instead.
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.)
Accepted Answer
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');
0 Comments
More Answers (0)
See Also
Categories
Find more on Spreadsheets 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!