# How can I get the standard error of each row of a matrix?

90 views (last 30 days)
Olivia Parczyk on 1 Jun 2018
Commented: hxen on 29 Feb 2024
Hello,
I have a 8x30 matrix 'data' and need the mean and standard error of each row. I've figured out the mean
mean_data=mean(data(1:8,:))
but I have no idea about the standard error. I have tried to get the std of the mean, but no matter what I do I just jet the std of the whole matrix, not each row. I've tried for example:
std_mean=std(mean_data,[],2)
or
std_mean=std(mean(data(1:8,:)))
I'm probably really stupid, but I've just started Matlab two weks ago and fail at the easiest things....help would be appreciated!
hxen on 29 Feb 2024
Not stupid. We all start out struggling learning at first.

Star Strider on 1 Jun 2018
The standard error of the mean (link) is defined as the standard deviation divided by the square root of the number of samples:
std_err_mean = std(data,[],2)/sqrt(size(data,2)); % Standard Error Of The Mean (Row-Wise)
To calculate the 95% confidence intervals, continue with:
mean_data = mean(data,2); % Mean (Row-Wise)
P95 = tinv(0.975, size(data,2)-1); % Compute 95% Confidence Standard Deviation
CI95 = mean(data,2) + std_err_mean*[-1 1]*P95; % 95% Confidence Intervals (Row-Wise)
hxen on 29 Feb 2024
You're a very helpful person Star and very much appreciated. Many of you great people on this community have been super helpful.