Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
final_proj_group11/montecarlo.m
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
30 lines (25 sloc)
958 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | |
end | |
%Find descriptive statistics for set of delfections | |
avg = mean(w); | |
stdev = std(w); | |
end | |