How can I calculate the avarage and how can I plot a Gaussian curve?

4 views (last 30 days)
friedl hulsmans on 4 Dec 2017
Commented: friedl hulsmans on 8 Dec 2017
N = 10;
for i = 1 : N
% Betondekking c1 = 40 - 10; c2 = 40 + ((600/210) + (275/21)); c = c1 + rand * (c2 - c1);
% Betonkwaliteit fck = 26 + rand * (34-26);
% Breedte b1 = 300 - ((300/50)+7); b2 = 300 + ((300/50)+7); b = b1 + rand * (b2 - b1);
% Hoogte h1 = 600 - ((600/140)+(85/7)); h2 = 600 + ((600/140) + (85/7)); h = h1 + rand * (h2 - h1);
% Diameter beugels qb = 9.9775+rand *(10.0225-9.9775);
% Diameter trekwapening qs1 = 24.9775+ rand * (25.0225-24.9775);
% Aantal staven trekwapening ns1 = 2;
% Diameter drukwapening qs2 = 13.9775+ rand * (14.0225-13.9775);
% Aantal staven drukwapening ns2 = 2;
% Kruipfactor q1 = 0.8*1.5; q2 = 1.4 * 1.5; q = q1 + rand * (q2 - q1);
% Moment in GGT-Q med = 96 * (10^6)+ rand * (144 * (10^6) - 96 * (10^6));
% Elasticiteitsmodulus staal Es = 200000;
% Staalkwaliteit fyk = 500;
% Gemiddelde waarde van de drukstrekste van beton fcm = fck + 4 +rand * (12 - 4) ;
% Elasticiteitsmodulus beton Ecm = 22000*((fcm/10)^0.3);
Ec = Ecm / (1 + q);
% Alpha alpha = Es / Ec;
% Afstand getrokken rand tot zwaartepunt wapening As1 d1 = c + qb + (qs1/2);
% Afstand gedrukte rand tot zwaartepunt wapening As2 d2 = c + qb + (qs2/2);
% Nuttige hoogte d = h - d1;
% Trekwapening As1 = (pi * ns1 * (qs1^2))/4;
% Drukwapening As2 = (pi * ns2 * (qs2^2))/4;
% Totale wapening Astot = As1 + As2;
% Drukhoogte x = ((-alpha Astot)/b)+ sqrt(((alpha*Astot/b)^2)+((2*alpha(As1*d+As2*d2))/b));
% Scheurmoment fctm = 0.3 * (fck ^(2/3));
% Traagheidsmoment I = ((b*(x^3)/3))+ alpha * As1*((d-x)^2)+ alpha * As2*((x-d2)^2);
% sigmac = med*x /I;
% sigmas = alpha * sigmac * (d-x)/x;
h1 = (h-x)/3; h2 = 2.5*(h-d); h3 = h/2; H = [h1 h2 h3]; Aceff = b*min(H);
rhoeff = As1/Aceff;
Srmax1 = 3.4 * c + 0.17* qs1 / rhoeff; Srmax2 = 1.3 * (h - x); Srmax = min(Srmax1 , Srmax2);
epsilon1 = 0.6*sigmas/200000; epsilon2 = (sigmas / 200000)-(0.4*fctm*(1+alpha*rhoeff)/(rhoeff*200000)); epsilon = max(epsilon1,epsilon2);
wk = Srmax*epsilon
plot(wk,i,'.') end
xlabel('scheurwijdte')
I tried to plot a Gaussian curve a explain but is doesn't work. Can someone help me? I also want to calculate the avarage but it just gives me the last calculated number? Can someone help me with this? Or is can I make a histogram ? And How?
friedl hulsmans on 8 Dec 2017
I have attach the file. The variable wk is supposed to creat the Gaussian curve of the histogram

Elizabeth Reese on 8 Dec 2017
If you want to create a histogram of wk, then you want wk to be an array where element i is from the i th iteration of the loop. In your attached script, you have N = 1, so there would only be one element. It looks like you originally wanted this to be N = 10.
In order to save the results from each iteration, you can add a line before the loop to initialize wk to be an array of length N.
wk = zeros(1,N);
Then, inside the loop, you would change
wk = Srmax*epsilon;
to
wk(i) = Srmax*epsilon;
This would save the iteration's wk value into the array.
After the loop, you can plot and average the wk array. For the histogram, you can let MATLAB calculate the number of bins using
histogram(wk)
or specify the number using
histogram(wk,numberOfBins)
To calculate the average, use
avgWk = mean(wk);
friedl hulsmans on 8 Dec 2017
Thank u. I get a histogram now. But how can I change the figure I have attached to just 1 histogram ? Without the black part and how can I change the number on the axes?