How to save a text file as a .mat file?
23 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (4)
KSSV
am 8 Nov. 2018
Bearbeitet: KSSV
am 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 Kommentare
KSSV
am 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
am 8 Nov. 2018
Matrix=load('sample.txt') %assuming text file is numeric
save sample.mat Matrix
0 Kommentare
CuriousThinker
am 9 Nov. 2018
Bearbeitet: CuriousThinker
am 9 Nov. 2018
3 Kommentare
Walter Roberson
am 9 Jan. 2025
Be careful, your filename probably does not end in a space.
wifi_motion = importdata('wifi_motion.txt') ;
Siehe auch
Kategorien
Mehr zu Text 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!