How i load a column of float numbers to a vector from a txt file
2 次查看(过去 30 天)
显示 更早的评论
Hi,
I am a matlab beginer and i want to know how load a column of floating number from a txt file. the file hasnt chars (only numbers) as shown below:
-0.000030517578125
+0.0
-0.000030517578125
-0.000030517578125
-0.000030517578125
-0.49969482421875
-0.000030517578125
-0.000030517578125
+0.0
-0.000030517578125
-0.000030517578125
-0.000030517578125
-0.000030517578125
+0.0001220703125
thanks !!
回答(2 个)
Sachin Ganjare
2012-10-30
NumHeaders = 17; %for example
NumDataLines = 1234; %for example
ColNum = 8; %for example
fmt = [ repmat('%*s',1,ColNum-1), '%f%[^\n'] ];
fid = fopen('C:\...\yourfilename.txt', 'rt');
data = textscan(fid, fmt, NumDataLines, 'HeaderLines', NumHeader);
fclose(fid);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Large Files and Big Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!