固定格式的数据txt文件,如何用MATLAB读取,并保存在矩阵中。
Model,DPO4104FirmwareVersion,2.13PointFormat,Y,,,PointFormat,YHorizontalUnits,S,,,Hor...
Model,DPO4104
Firmware Version,2.13
Point Format,Y,,,Point Format,Y
Horizontal Units,S,,,Horizontal Units,S
Horizontal Scale,0.001,,,Horizontal Scale,0.001
Sample Interval,1e-08,,,Sample Interval,1e-08
Record Length,1e+06,,,Record Length,1e+06
Gating,0.0% to 100.0%,0.0% to 100.0%,,Gating,0.0% to 100.0%
Probe Attenuation,1000,10,,Probe Attenuation,1
Vertical Units,V,V,,Vertical Units,V
Vertical Offset,0,0,,Vertical Offset,0
Vertical Scale,5000,5,,Vertical Scale,10
Label,,,,Label,Uc
TIME,CH1,CH3,,TIME,MATH
-5.000000e-03,-497.656,0.526563,,-5.000000e-03,-5.60781
-4.999990e-03,-460.156,0.330469,,-4.999990e-03,-5.41172
-4.999980e-03,-371.875,0.328125,,-4.999980e-03,-5.40859
-4.999970e-03,-304.688,0.448438,,-4.999970e-03,-5.52969
-4.999960e-03,-346.875,0.375,,-4.999960e-03,-5.45625
-4.999950e-03,-372.656,0.567969,,-4.999950e-03,-5.64922
-4.999940e-03,-564.062,0.358594,,-4.999940e-03,-5.43984
-4.999930e-03,-450.781,0.44375,,-4.999930e-03,-5.525
-4.999920e-03,-472.656,0.417188,,-4.999920e-03,-5.49844
.....(之后还有很多列)
前几行是题头,可以跳过。 之后的数据每列之间用逗号隔开的。如果数据用空格隔开,textread就能搞定。但是逗号分隔就不知道怎么处理了。 展开
Firmware Version,2.13
Point Format,Y,,,Point Format,Y
Horizontal Units,S,,,Horizontal Units,S
Horizontal Scale,0.001,,,Horizontal Scale,0.001
Sample Interval,1e-08,,,Sample Interval,1e-08
Record Length,1e+06,,,Record Length,1e+06
Gating,0.0% to 100.0%,0.0% to 100.0%,,Gating,0.0% to 100.0%
Probe Attenuation,1000,10,,Probe Attenuation,1
Vertical Units,V,V,,Vertical Units,V
Vertical Offset,0,0,,Vertical Offset,0
Vertical Scale,5000,5,,Vertical Scale,10
Label,,,,Label,Uc
TIME,CH1,CH3,,TIME,MATH
-5.000000e-03,-497.656,0.526563,,-5.000000e-03,-5.60781
-4.999990e-03,-460.156,0.330469,,-4.999990e-03,-5.41172
-4.999980e-03,-371.875,0.328125,,-4.999980e-03,-5.40859
-4.999970e-03,-304.688,0.448438,,-4.999970e-03,-5.52969
-4.999960e-03,-346.875,0.375,,-4.999960e-03,-5.45625
-4.999950e-03,-372.656,0.567969,,-4.999950e-03,-5.64922
-4.999940e-03,-564.062,0.358594,,-4.999940e-03,-5.43984
-4.999930e-03,-450.781,0.44375,,-4.999930e-03,-5.525
-4.999920e-03,-472.656,0.417188,,-4.999920e-03,-5.49844
.....(之后还有很多列)
前几行是题头,可以跳过。 之后的数据每列之间用逗号隔开的。如果数据用空格隔开,textread就能搞定。但是逗号分隔就不知道怎么处理了。 展开
2个回答
展开全部
将你的数据(不带文字)列好,保存为shuju.txt(文件名随意),然后放在你保存MATLAB程序的文件夹中,程序中写load shuju.txt; a=shuju; 这样a就是你的数据矩阵了!
更多追问追答
追问
能否保证不改变原txt,直接读取数据呢?(txt都是几百M,打开修改很费时间)
追答
可以试试excel导入,num=xlsread('filename','range')读filename中第一页的指定区域的数据到矩阵中。例如num=xlsread('a1.xls','A2:G2')
[num,txt,raw]=xlsread('filename',.....)读filename中的数据,并返回数值数据到double型数组num中,非数值的文本到字符串单元数组txt中,未处理的单元数据到字符串单元数组raw中。raw中包含数值数据和文本数据。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |