Hi, I've tried to run a while loop a hundred times with a for loop. My goal is to store the counting variable (k) from each while-loop In a vector, and then take the mean of this vector. I've coded it this way;
Q = zeros(1,100); for (ii) = 1 : 100 k = 0 ; %counting variabel
sum = 0; critical_value = 1.9; while sum<critical_value sum = rand(1) + rand(1) ; k = k + 1; end Q(1,k) = k; endW = mean(Q(1,k));
My problem is that the values I try to store donĀ“t really make sense compared to what I intended it to be. The end goal of this project is to test the mean of the stored counting variables against an predetermined expected value.
Do anyone have a suggestion on how to solve my problem?
Best Answer