bfield 发表于 2011-3-18 18:14

请问怎样将.txt文件的数据导入matlab中,且数据精度不变呢

实验中采集的振动数据,精度是小数点后8位,结果通过load和importdata导入数据时,精度被减少到小数点后4位。怎样导入才能保持数据不变呢。谢谢

nuonuo 发表于 2011-3-18 19:21

正在学习中,A=fscanf(fid,format)
=fscanf(fid,format,size) =fscanf(fid,format,size)

ChaChing 发表于 2011-3-18 20:57

回复 1 # bfield 的帖子

...精度被减少到小数点后4位...
不是这样的, help format!

zhouyang664 发表于 2011-3-18 21:01

format long
四位只是显示,精度还是在的!

ChaChing 发表于 2011-3-18 21:02

nuonuo 发表于 2011-3-18 19:21 static/image/common/back.gif
正在学习中,A=fscanf(fid,format)
=fscanf(fid,format,size) =fscanf(fid,format,si ...

好奇问下, 这是回应LZ问题, 还是问问题?
说明下, fscanf是以格式方式读入, 可能不是LZ遇到的问题!

bfield 发表于 2011-3-22 17:54

回复 4 # zhouyang664 的帖子

好像都不行哦。我把一小段数据发出来,可以试一试。好像第四位后面的都被四舍五入了。

zhouyang664 发表于 2011-3-22 21:21

这不是很正常吗?
>> format long
>> sy

sy =

Columns 1 through 3

                   0   0.000724760000000   0.002126060000000
   0.000195310000000   0.000792090000000   0.002072840000000
   0.000390630000000   0.000756510000000   0.002033560000000
   0.000585940000000   0.000736190000000   0.002056370000000
   0.000781250000000   0.000745090000000   0.002029760000000
   0.000976560000000   0.000779390000000   0.002114660000000
   0.001171880000000   0.000766680000000   0.002014550000000
   0.001367190000000   0.000696810000000   0.002061440000000
   0.001562500000000   0.000766680000000   0.002034830000000
   0.001757810000000   0.000775570000000   0.002052570000000
   0.001953120000000   0.000806060000000   0.002004420000000
   0.002148440000000   0.000766680000000   0.002023430000000
   0.002343750000000   0.000741270000000   0.002051300000000
   0.002539060000000   0.000764140000000   0.002029760000000
   0.002734380000000   0.000804790000000   0.002052570000000
   0.002929690000000   0.000728560000000   0.002046240000000
   0.003125000000000   0.000773030000000   0.002042440000000
   0.003320310000000   0.000737460000000   0.002069040000000
   0.003515630000000   0.000757790000000   0.002046240000000
   0.003710940000000   0.000778110000000   0.002031030000000
   0.003906250000000   0.000770490000000   0.002041170000000
   0.004101560000000   0.000750160000000   0.002062710000000
   0.004296880000000   0.000734920000000   0.002067780000000
   0.004492190000000   0.000793360000000   0.002038630000000
   0.004687500000000   0.000784460000000   0.002060170000000
   0.004882810000000   0.000701890000000   0.002046240000000
   0.005078130000000   0.000764140000000   0.002089320000000
   0.005273440000000   0.000746350000000   0.002039900000000

Columns 4 through 6

-0.001447120000000   0.000307200000000   0.000501550000000
-0.001377220000000   0.000316080000000   0.000437890000000
-0.001414070000000   0.000286880000000   0.000464630000000
-0.001388660000000   0.000285620000000   0.000482450000000
-0.001430600000000   0.000316080000000   0.000435340000000
-0.001436950000000   0.000295770000000   0.000453160000000
-0.001386120000000   0.000286880000000   0.000516840000000
-0.001433140000000   0.000286880000000   0.000541020000000
-0.001434400000000   0.000253880000000   0.000492640000000
-0.001433140000000   0.000276720000000   0.000506650000000
-0.001384850000000   0.000267840000000   0.000464630000000
-0.001419160000000   0.000267840000000   0.000515560000000
-0.001415350000000   0.000261500000000   0.000478630000000
-0.001396290000000   0.000257690000000   0.000468450000000
-0.001386120000000   0.000299580000000   0.000509190000000
-0.001431860000000   0.000288150000000   0.000497740000000
-0.001392480000000   0.000265310000000   0.000474820000000
-0.001386120000000   0.000274190000000   0.000501550000000
-0.001379760000000   0.000321160000000   0.000482450000000
-0.001365780000000   0.000303390000000   0.000506650000000
-0.001420430000000   0.000326230000000   0.000518100000000
-0.001374680000000   0.000335120000000   0.000499000000000
-0.001401370000000   0.000322420000000   0.000514290000000
-0.001386120000000   0.000337660000000   0.000434070000000
-0.001397550000000   0.000341470000000   0.000490090000000
-0.001405180000000   0.000304650000000   0.000547390000000
-0.001393740000000   0.000270380000000   0.000502830000000
-0.001433140000000   0.000291960000000   0.000491370000000

Columns 7 through 9

   0.001598910000000   0.002120250000000-0.000570140000000
   0.001616690000000   0.002080910000000-0.000606750000000
   0.001590020000000   0.002059340000000-0.000590340000000
   0.001582390000000   0.002107560000000-0.000613060000000
   0.001590020000000   0.002094870000000-0.000587810000000
   0.001579860000000   0.002063150000000-0.000590340000000
   0.001543020000000   0.002082180000000-0.000594130000000
   0.001531590000000   0.002096140000000-0.000553730000000
   0.001614150000000   0.002094870000000-0.000595390000000
   0.001597640000000   0.002092330000000-0.000507010000000
   0.001573510000000   0.002070760000000-0.000575180000000
   0.001543020000000   0.002129120000000-0.000594130000000
   0.001506180000000   0.002105020000000-0.000572660000000
   0.001521430000000   0.002092330000000-0.000591590000000
   0.001596370000000   0.002082180000000-0.000595390000000
   0.001587480000000   0.002082180000000-0.000536050000000
   0.001540480000000   0.002078380000000-0.000543620000000
   0.001582390000000   0.002139280000000-0.000567610000000
   0.001595090000000   0.002116440000000-0.000553730000000
   0.001569700000000   0.002097400000000-0.000582770000000
   0.001595090000000   0.002122780000000-0.000539840000000
   0.001596370000000   0.002182420000000-0.000582770000000
   0.001616690000000   0.002087250000000-0.000605490000000
   0.001607800000000   0.002072030000000-0.000563820000000
   0.001560800000000   0.002120250000000-0.000580230000000
   0.001576040000000   0.002145620000000-0.000586550000000
   0.001577320000000   0.002056810000000-0.000649670000000
   0.001612880000000   0.001981940000000-0.000562570000000

bfield 发表于 2011-3-23 11:27

zhouyang664 发表于 2011-3-22 21:21 static/image/common/back.gif
这不是很正常吗?
>> format long
>> sy


谢谢,是的,其实是显示的问题。

玉林 发表于 2011-7-27 15:10

是显示的问题,我也遇到过,你可以看看那个变量栏里的,没问题的

F117_ren_0 发表于 2011-8-2 19:07

用textread

ChaChing 发表于 2011-8-3 00:52

F117_ren_0 发表于 2011-8-2 19:07 static/image/common/back.gif
用textread

好像与用那个函数输入无关!

manguoyong 发表于 2011-11-20 11:00

{:{40}:}

0810064 发表于 2011-12-3 19:01

编一段matlab程序实验数据是可以导入的,论坛里面有。但我不知能否保留精度到楼主所需要

华尚 发表于 2011-12-6 13:16

我还是没太懂,能再仔细详述一下吗?不胜感激!

ChaChing 发表于 2011-12-8 00:35

真的是没太多时间回应!
简单的说, matlab所採用预设的已经是双精确度(double precision), 8个bytes, 大约15~16位十进位精确度, 够了吧
页: [1] 2
查看完整版本: 请问怎样将.txt文件的数据导入matlab中,且数据精度不变呢