我有一個文本文件(C:\ input.txt中),其中有:這是什麼錯誤[從Matlab中的文本文件讀取輸入]?
2.0 4.0 8.0 16.0 32.0 64.0 128.0 256.0 512.0 1024.0 2048.0 4096.0 8192.0
在Matlab中,我想它讀成:
data = [2.0 4.0 8.0 16.0 32.0 64.0 128.0 256.0 512.0 1024.0 2048.0 4096.0 8192.0]
我試過這段代碼:
fid=fopen('c:\\input.txt','rb');
data = fread(fid, inf, 'float');
data
,但我得到一些垃圾值:
data =
1.0e-004 *
0.0000
0.0015
0.0000
0.0000
0.0000
0.0000
0.0000
0.0001
0.0239
0.0000
0.0000
0.0000
0.0000
0.0066
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0016
0.0000
0.0000
0.0276
0.0000
0.3819
0.0000
0.0000
錯誤在哪裏?