Skip to content
Go to file
Cannot retrieve contributors at this time
30 lines (25 sloc) 958 Bytes
function [avg,stdev]=montecarlo(num)
%Generates random values for base and height values
%of the beam, finds according mean and standard deviation
%of the outputted deflections.
%Applied distributed load given as 50 N/m.
%Normal random number generation using 0.1% standard deviation.
%Input 'num' designates number of random samples.
%Given physical parameters
q = 50; %Input loading 50 N/m
E = 70*10^9; %Pa
l = 1; %m
x = 0.5; %m
%Loop generates random numbers and places calculated deflections in matrix
for i=1:num
%Generates random values for I
b = normrnd(0.1,0.01); %random base length
h = normrnd(0.01,0.001); %random height value
I = (b*h^3)/12; %calculates random Moment of Inertia (m^4)
%Calculated corresponding deflections and place in matrix w
w(i) = -(((q*l*(x^3))/(12*E*I)))-(((q*(x^4))/(24*E*I)))-((q*(l^3)*x)/(24*E*I));
%Find descriptive statistics for set of delfections
avg = mean(w);
stdev = std(w);
You can’t perform that action at this time.