1
我安排我的升序排列的代碼。我需要做一個正常的數據分佈。我需要有random8和隨機24.我懷疑大中小型的陣列可以做正態分佈,也發現了平均值和標準偏差。因此,我怎麼能隨機8做,random24 下面是我的代碼:如何計算的立場偏差和平均
symbols = {'SMALL', 'MEDIUM', 'LARGE'};
range = 101; % <-- Or 101 if you want from 0 to 100 with 100 included
rndInd = randi(numel(symbols), range ,1);
st = symbols(rndInd);
strjoin(st);
random24 = strtrim(cellstr(num2str(randi(24, range, 1))));
random8 = strtrim(cellstr(num2str(randi(8, range, 1))));
b = num2cell(sort(randi(24, range, 1)));
B = cellfun(@num2str, b, 'UniformOutput', false);
%B = sort(random24)
st = [ st' B random8 ]
%% MEAN
mean8=mean(random8);
fprintf('Mean of Random 8 parking Duration is %f',mean8);
mean24=mean(random24);
fprintf('Mean of Random 24 Hours is %f',mean24);
%% Standard deviation
standDev8= std(random8);
fprintf('Standard Deviation of Random 1-8 Hours of parking Duration is %f',standDev8);
figure(1);
histogram(random8);
title('Histogram of Data for Random 1-8 Hours of parking Duration')
standDev24= std(random24);
fprintf('Standard Deviation of Random 24 Hours is %f',standDev24);
figure(2);
histogram(random24);
title('Histogram of Data for Random 24Hours ')
錯誤消息我得到 未定義功能「和」類型「細胞」的輸入參數。
Error in mean (line 116)
y = sum(x, dim, flag)/size(x,dim);
Error in RANDOM (line 15)
mean8= mean(B);