MATLAB: Finding the mean of a matrix row? Get error “Subscript indices must either be real positive integers or logicals.”

columnerrormatrixmeanrowstatssubscript indices must either be real positive integers or logicals.

If I have the following matrix as an output from my code;
Xtcounter =
0 4 4 4 0
0 4 4 4 0
0 4 4 4 0
0 4 4 4 0
3 4 4 1 0
2 4 4 2 0
2 4 4 2 0
2 4 4 2 0
2 4 4 2 0
2 4 4 2 0
2 4 4 2 0
2 4 4 2 0
2 4 4 2 0
2 4 4 2 0
2 4 4 2 0
2 4 4 2 0
2 4 4 2 0
2 4 4 2 0
2 4 4 2 0
2 4 4 2 0
2 4 4 2 0
2 4 4 2 0
2 4 4 2 0
2 4 4 2 0
2 4 4 2 0
2 4 4 2 0
2 4 4 2 0
2 4 4 2 0
2 4 4 2 0
2 4 4 2 0
2 4 4 2 0
2 4 4 2 0
2 4 4 2 0
2 4 4 2 0
where each row represents particle's positions along the axis at a time.
I want to find the mean value of each row but it wont let me, I have tried various methods such as
A=Xtcounter(2,:) M=mean(A)
but get the error message;
Subscript indices must either be real positive integers or logicals.
If anyone could help it would be so appreciated!! As i will need to be able to do standard deviation, kurtosis and skewness of each row after!
Thanks in advance!!

Best Answer

Use
A = mean(Xtcounter,2)
B = std(Xtcounter,0,2)
C = kurtosis(Xtcounter')'