Please, how do I fix a for loop to store some counters obtained from a while loop.
close all;clear;clc;NumberofSimulation = 10; % Number of simulations
StoreCounter = zeros(1,NumberofSimulation); % Stores the counters,
% StoreCounter = [11
for kk = 1: length(NumberofSimulation)counter = 0; % Initializes the counter
ii = 1;while ii <= 20 temp = randi([25 40]); if temp >= 30 counter = counter + 1; end ii = ii + 1; fprintf('kk = %d, ii = %d \n',kk,ii)% iterates aonly once. Thus, can it
%iterate more.
endStoreCounter(kk) = counter; % This does not work, please. Only the counter
% obtained by first simulation is stored in the vector, StoreCounter.
end
Best Answer