How to load a file
显示 更早的评论
Hi,
To load a file, I always do this: load file.txt
But this time, my file looks like what I have pasted below.
‘load’ does not work.
How can I load a file so I can put the data into an array?
Thank you for your help.
Herve
/********************************/
The file
(6.278305337995641,-31.165930909567250)
(1.758723282034028,-1.229391225298848)
(1.133464180020400,-3.392317005428029E-001)
(3.528019029863541,9.833493189283731E-001)
(-1.589297342018588,-6.805368090065715E-001)
(-5.740909803957738E-002,5.972384666809710E-001)
(2.903057010297026E-001,-1.201455315950079E-001)
(8.626581493421666E-001,-6.836608234777217E-002)
(-1.805284473824767E-001,-5.614038990230759E-001)
(2.126569179381342,-2.150085377308474)
…
采纳的回答
更多回答(1 个)
Kelly Kearney
2011-10-21
Textscan is probably your best bet here, assuming you want an n x 2 array of the paired data points. Try:
fid = fopen('file.txt');
data = textscan(fid, '(%f,%f)', 'collectoutput', true);
fclose(fid);
data = data{1};
3 个评论
Hervé Chubaka Bagalwa
2011-10-21
Hervé Chubaka Bagalwa
2011-10-21
Hervé Chubaka Bagalwa
2011-10-22
类别
在 帮助中心 和 File Exchange 中查找有关 Text Data Preparation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!