MATLAB: Error in using the sum function

MATLABsum function

I am getting an error I can't understand.
I attached the code and a photo.
thanks!
clear all
close all
clc
m=5; %number of groups
n=10 %size of each group
sz=[m n];
sum=0;
G=0+(100-0)*rand([sz]);
G1=G(1,:);
sum(G1);

Best Answer

You are defining a variable named sum here
sum=0;
and then later you try to index that variable by a vector of non-integers. It's like doing this:
v= 6;
v([310.15324, 235.3463, 501.346])
If you're trying to use the sum() function, you'll need to use a different variable name.