0

thıs ıs my code ... but tehere ıs a problem ı guess about my type defınıtıon...

fat=[9.5 26.5 7.8 17.8 31.4 25.9 27.4 27.2 31.2 34.6 42.5 28.8 33.4 30.2 34.1 32.9 41.2 35.7]
fatSum=0;
for j:18
    fatSum=fatSum+fat(1,i)
end
fatMean=fatSum/18
Yilmaz Paçariz
  • 186
  • 1
  • 4
  • 18
  • 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 15:42

1 Answers1

2

Your loop statement is broken. Where you have for j:18 you should have for j = 1:18.

Your loop is unnecessary. You can sum the elements in an array like this: fatsum = sum(fat).

High Performance Mark
  • 77,191
  • 7
  • 105
  • 161