- https://www.mathworks.com/help/stats/bootci.html
- https://www.mathworks.com/help/matlab/ref/squeeze.html
bootci for 3d
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
my data is M, 200x2x75. should the format be 2x200x75? (75 participants)
i want CIs for each row in the first colum, and then for second.
I have this code but I am not sure i fully understand it.
for x=1:200
for y=1:2
ci_200x2=bootci(1000,@mean,M(x,y,:));
all_ci_200x200(x,y)={transpose(ci_200x2)};
end
end
0 Commenti
Risposte (1)
Paras Gupta
il 9 Set 2023
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.
Hope it helps.
0 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!