Problem with loop MATLAB

Posted by Jessy on Stack Overflow See other posts from Stack Overflow or by Jessy
Published on 2010-06-02T13:04:17Z Indexed on 2010/06/02 14:13 UTC
Read the original article Hit count: 179

Filed under:
|
|
no  time  scores
1    10    123
2    11    22
3    12    22
4    50    55
5    60    22
6    70    66
.    .     .
.    .     .
n    n     n 

Above a the content of my txt file (thousand of lines).

1st column - number of samples
2nd column - time (from beginning to end ->accumulated)
3rd column - scores

I wanted to create a new file which will be the total of every three sample of the scores divided by the time difference of the same sample.

e.g. (123+22+22)/ (12-10) = 167/2 = 83.5
     (55+22+66)/(70-50) = 143/20 = 7.15

new txt file

83.5
7.15
.
.
.
n

so far I have this code:

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
....

© Stack Overflow or respective owner

Related posts about matlab

Related posts about loops