How to save a text file as a .mat file?
16 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (4 件)
KSSV
2018 年 11 月 8 日
編集済み: KSSV
2018 年 11 月 8 日
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 件のコメント
KSSV
2018 年 11 月 9 日
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
2018 年 11 月 8 日
Matrix=load('sample.txt') %assuming text file is numeric
save sample.mat Matrix
0 件のコメント
CuriousThinker
2018 年 11 月 9 日
編集済み: CuriousThinker
2018 年 11 月 9 日
3 件のコメント
Walter Roberson
2025 年 1 月 9 日
Be careful, your filename probably does not end in a space.
wifi_motion = importdata('wifi_motion.txt') ;
参考
カテゴリ
Help Center および File Exchange で Text Files についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!