How to save a text file as a .mat file?
16 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
I have a text file having data with each row having the format: a1,a2,a3,a4. I have close 2k such rows. I need to save the full text file as a .mat file. How do I get that? I already tried tetxscan but I run into cell within cell issue. Appreciate help.
0 commentaires
Réponses (4)
KSSV
le 8 Nov 2018
Modifié(e) : KSSV
le 8 Nov 2018
data = importdata('myfile) ;
save data.mat -v7.3
Using textscan
fid = fopen(myfile) ;
S = textscan(fid,'%f %f %f %f') ;
fclose(fid) ;
a1 = S{1} ; a2 = S{2} ; a3 = S{3} ; a4 = S{4} ;
save data.mat -v7.3 ;
4 commentaires
KSSV
le 9 Nov 2018
data = importdata('data.txt') ; % you can use load also
save data.mat -v7.3
It is giving you the full data in text file.
madhan ravi
le 8 Nov 2018
Matrix=load('sample.txt') %assuming text file is numeric
save sample.mat Matrix
0 commentaires
CuriousThinker
le 9 Nov 2018
Modifié(e) : CuriousThinker
le 9 Nov 2018
3 commentaires
Walter Roberson
le 9 Jan 2025
Be careful, your filename probably does not end in a space.
wifi_motion = importdata('wifi_motion.txt') ;
Voir également
Catégories
En savoir plus sur Text 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!