How to save a text file as a .mat file?
19 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (4)
KSSV
el 8 de Nov. de 2018
Editada: KSSV
el 8 de Nov. de 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 comentarios
KSSV
el 9 de Nov. de 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
el 8 de Nov. de 2018
Matrix=load('sample.txt') %assuming text file is numeric
save sample.mat Matrix
0 comentarios
CuriousThinker
el 9 de Nov. de 2018
Editada: CuriousThinker
el 9 de Nov. de 2018
3 comentarios
Walter Roberson
el 9 de En. de 2025
Be careful, your filename probably does not end in a space.
wifi_motion = importdata('wifi_motion.txt') ;
Ver también
Categorías
Más información sobre Text Files en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!