讀我有一個txt文件,每個由製表符分隔線總是兩個值:Matlab的:從txt文件
0 0
23 69
45 108
81 158
110 253
125 357
141 492
165 606
179 753
189 983
. .
0 0
4 31
33 38
45 89
60 115
75 166
93 201
107 216
116 291
133 366
148 480
170 631
196 720
207 994
. .
0 0
19 81
33 102
46 128
72 161
138 236
178 398
197 537
210 658
220 832
. .
0 0
24 38
40 90
71 166
99 193
等
始終以0開頭和結尾。 。 (80次)
我想用Matlab讀取所有的數據。這是我的代碼:
% Variab
line{1} = 0;
% Open files
fid = fopen(('D:\Dokumente\Studium\8. Semester\BA\Vali mit einzelenne punkten\alle.txt'), 'rt');
% Read Data
for i = 1:80
j = 1;
line = fgets(fid);
line = textscan(line,'%f %f');
while line{1} ~= '.'
digNum{i}(j) = line{1};
gewicht{i}(j) = line{2};
line = fgets(fid);
line = textscan(line,'%f %f');
j = j + 1;
end
end
因此,大家可以看到我想要的左邊的數字保存爲digNum {「‘upOneValueWhen} {numberIn'Vector’}和右邊的數字gewicht {upOneValueWhen」。'} {numberIn'Vector'}。
一切工作正常,但當我得到digNum = 46(第二個到最後一個「矢量」){upOneValueWhen'。'}上升一個數字。 我不知道爲什麼。 '我'應該只在'後'上升。但由於某種原因,它在這一特定點上升。
任何想法??? 非常感謝你提前
您的示例數據不會重現您的問題。 – excaza
你需要我複製粘貼所有數據嗎? –
需要的是一個重現問題的例子。 – excaza