Yilmaz Paçariz
Yilmaz Paçariz

Reputation: 186

Subscript indices must either be real positive integers or logicals in an array

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

Upvotes: 0

Views: 415

Answers (1)

High Performance Mark
High Performance Mark

Reputation: 78316

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

Upvotes: 2

Related Questions