Hi Miri,
I understand you want to compute the confidence intervals for each row in a data matrix of size 200x2x75 separately for the two columns (specified by the second dimension).
The code provided uses for loops to access each row and each column of the data matrix, and then uses ‘bootci’ function on the elements in the matrix M(x, y, :). The ‘bootci’ function returns a vector output with two rows. The code provided takes the transpose of the output vector to convert into a row vector.
You can refer to the code below for a more accurate version.
% Dummy data
M = randn(200, 2, 75);
% Calculate confidence intervals
all_ci_200x200 = cell(200, 2); % Preallocate the cell array to store the CIs
% Using the squeeze function to get rid of the singleton dimensions
for x = 1:200
for y = 1:2
ci_200x2 = bootci(1000, @mean, squeeze(M(x, y, :)));
all_ci_200x200{x, y} = ci_200x2';
end
end
% Display the confidence intervals for the first row in the first column
disp(all_ci_200x200{1, 1});
The above code uses the squeeze function in MATLAB to get rid of the singleton dimensions in M(x, y,:) . You can refer to the following documentation for more information on the code.
- https://www.mathworks.com/help/stats/bootci.html
- https://www.mathworks.com/help/matlab/ref/squeeze.html
Hope it helps.