no time scores
1 10 123
2 11 22
3 12 22
4 50 55
5 60 22
6 70 66
. . .
. . .
n n n
以上我的txt文件(千行)的內容。問題與循環MATLAB
1st column - number of samples
2nd column - time (from beginning to end ->accumulated)
3rd column - scores
我想創建一個新的文件,這將是總由同一樣本的時間差分的分數每三個樣品。
e.g. (123+22+22)/ (12-10) = 167/2 = 83.5
(55+22+66)/(70-50) = 143/20 = 7.15
新的txt文件
83.5
7.15
.
.
.
n
到目前爲止,我有這樣的代碼:
fid=fopen('data.txt')
data = textscan(fid,'%*d %d %d')
time = (data{1})
score= (data{2})
for sample=1:length(score)
..... // I'm stucked here ..
end
....
你能保證'n'是3的倍數嗎? – Jacob 2010-06-02 13:20:51
沒有。如果剩餘的小於3,例如1或2個樣本,它會放棄它。 – Jessy 2010-06-02 13:32:51