0

I'm new to MatLab, I have a Matrix:

first column: time in min, eg, 0, 0.5,1,1.5,2…up to 105,5 min

second column: distance measures

How can I plot the average values of distance each 5 min I wrote this:

data_to_plot = mean(data((i-1)*5:i*5))

I got the answer “Subscript indices must either be real positive integers or logicals.”

Brandon Moretz
  • 7,512
  • 3
  • 33
  • 43
  • If you want 5 minutes average you need multiply by 10 (5min / 0.5 min) and add 1 to first index, e.g. convert to data((i-1)*10+1 : i*10) – Danil Asotsky Mar 15 '13 at 13:56
  • Also see [this question](http://stackoverflow.com/questions/20054047/subscript-indices-must-either-be-real-positive-integers-or-logicals-generic-sol) for [the generic solution to this problem](http://stackoverflow.com/a/20054048/983722). – Dennis Jaheruddin Nov 27 '13 at 16:05

1 Answers1

0

Have you checked your definition of i? If i starts at 1, then the first entry from data((i-1)*5:i*5) will be zero, and MATLAB's arrays are indexed from 1.

Skipsh
  • 33
  • 5