סימולציה עבודה מספר 5

You might also like

You are on page 1of 5

5

288565660 :
:1
: . '
POLYFIT-
BASIC FITTING TOOL-
'
'
:
H=[61 69 68 69 68 64 68 74 75 68 68 73 70 66 64 73 67 71 69 71 69 69
71 65];
W=[54 66 66 71 68 53 61 86 92 57 59 80 70 59 50 145 68 78 67 90 75 74
84 53];
figure,plot(H,W,'b*'),title('Height Vs
Weight');xlabel('Height');ylabel('Weight');
pol=polyfit(W,H,2);
range=min(H):max(H);
f_x = polyval(pol,range);
figure,plot(range,f_x),title('Polifit order
2');xlabel('Height');ylabel('Weight');
n= length(H);
r=(n*(H*W')-sum(H)*sum(W))/((n*norm(H)^2-sum(H)^2)*sqrt(n*norm(W)^2sum(W)^2)).^0.5;
fprintf('r coeff= %f\n',r);

Polifit order 2
70.5
70
69.5

Weight

69
68.5
68
67.5
67
66.5
60

65

70

75

Height

.0114

Height Vs Weight
150
data 1
quadratic

140
130
120

Weight

110
100
90
80
70
60
50
60

65

70

75

Height

:
<<r coeff: 15.860066
.

:2
b

: -

b=pi - a=0

y sin(2 x)dx

''
:
function int_mc=montacarlo(N)
h=pi/(N-1);
x=0:h:pi;
Y=inline('sin(2*pi*x)');
y=Y(x);
f_max=max(y);
f_min=min(y);
x_mont=pi*rand(1,N);
y_mont_min=f_min*rand(1,N);
y_mont_max=f_max*rand(1,N);
N_fmin=length(find(y_mont_min>Y(x_mont)));
N_fmax=length(find(y_mont_max<Y(x_mont)));
int_mc=pi*f_max*N_fmax/N+pi*f_min*N_fmin/N;

ymont=f_min+(f_max-f_min)*rand(1,N);
plot(x,y,'-b',x_mont,ymont,'.');

>> montacarlo(1000)
ans =
0.1194
1
0.8
0.6
0.4
0.2
0
-0.2
-0.4
-0.6
-0.8
-1

0.5

1.5

2.5

3.5

6
Q=0.24 cal : I=50.1A R=120.01
I ) Uniform Distribution( - .I2Rt
? )upper limit( cal 0022- () Q- .R-
.N=5000 t=120sec
. ( '' )
.

:
function precent=heat(R,R_error,I,I_error,t,N,Lim)
Rt=R+(R_error).*rand(1,N);
It=I+(I_error).*rand(1,N);
Q=0.24*(It.^2).*Rt.*t;
precent=100*sum(Q>=Lim)/N;
fprintf('Upper limit presentage: %f %\n',precent);
figure,hist(Q);hold on;
plot([Lim Lim],[0,max(hist(Q))],'r-*');

:
>> heat(10,0.01,5,0.1,120,5000,7400)
Upper limit presentage: 32.080000
ans =

32.0800
600

500

400

300

200

100

0
7200

7250

7300

7350

7400

7450

7500

You might also like