Professional Documents
Culture Documents
for f=1:7
for c=1:7
if ( f+c==2|f+c==3|f+c==4|f+c==5|f+c==6|f+c==7)
B(f,c)=0;
elseif f+c==8
B(f,c)=1;
elseif f+c==9
B(f,c)=2;
elseif f+c==10
B(f,c)=3;
elseif f+c==11
B(f,c)=4;
elseif f+c==12
B(f,c)=5;
elseif f+c==13
B(f,c)=6;
else
B(f,c)=7;
end
end
end
display(B)
B=
0 0 0 0 0 0 1
0 0 0 0 0 1 2
0 0 0 0 1 2 3
0 0 0 1 2 3 4
0 0 1 2 3 4 5
0 1 2 3 4 5 6
1 2 3 4 5 6 7
2)
for f=1:6
for c=1:6
if c==1
B(f,c)=32;
elseif c==2
B(f,c)=16;
elseif c==3
B(f,c)=8;
elseif c==4
B(f,c)=4;
elseif c==5
B(f,c)=2;
else
B(f,c)=1;
end
end
end
display(B)
B=
32 16 8 4 2 1
32 16 8 4 2 1
32 16 8 4 2 1
32 16 8 4 2 1
32 16 8 4 2 1
32 16 8 4 2 1
>>
3)
x=-3:0.05:3
y1=3.*x.^2;
y2=exp(x);
plot(x,y1,'r',x,y2,'b')
grid on
30
25
20
15
10
0
-3 -2 -1 0 1 2 3
>> a=-1,b=0,tol=5*10^-9
a=
-1
b=
tol =
5.000000000000000e-009
>> [c]=bisec('f11',a,b,tol)
c=
-0.458962269127369
>>
4
a)
clc
clear
k=1
while (1+(k+1))/(k*(k+1))> (5*(10^ -3))
U(k)=(2*k+2)/(2*k*(2*k+1));
k=k+1;
end
display(U)
k =
U =
Columns 1 through 6
0.666666666666667 0.300000000000000 0.190476190476190
0.138888888888889 0.109090909090909 0.089743589743590
Columns 7 through 12
Columns 13 through 18
Columns 19 through 24
Columns 25 through 30
Columns 31 through 36
Columns 37 through 42
Columns 43 through 48
Columns 49 through 54
Columns 55 through 60
Columns 61 through 66
Columns 67 through 72
Columns 73 through 78
0.006895909048551 0.006802104117540 0.006710816777042
0.006621947024424 0.006535400083787 0.006451086068920
Columns 79 through 84
Columns 85 through 90
Columns 91 through 96
0.002518859963980 0.002506234413965
>>
b)
clc
clear
k=1
while (2*k+2)/(2*k*(2*k+1))> 5*10^ -3
U(k)=(2*k+2)/(2*k*(2*k+1));
k=k+1;
end
display(U)
k =
1
U =
Columns 1 through 6
0.666666666666667 0.300000000000000
0.190476190476190 0.138888888888889 0.109090909090909
0.089743589743590
Columns 7 through 12
0.076190476190476 0.066176470588235
0.058479532163743 0.052380952380952 0.047430830039526
0.043333333333333
Columns 13 through 18
0.039886039886040 0.036945812807882
0.034408602150538 0.032196969696970 0.030252100840336
0.028528528528529
Columns 19 through 24
0.026990553306343 0.025609756097561
0.024363233665559 0.023232323232323 0.022201665124884
0.021258503401361
Columns 25 through 30
0.020392156862745 0.019593613933237
0.018855218855219 0.018170426065163 0.017533606078317
0.016939890710383
Columns 31 through 36
0.016385048643113 0.015865384615385
0.015377657168702 0.014919011082694 0.014486921529175
0.014079147640791
Columns 37 through 42
0.013693693693694 0.013328776486671
0.012982797792924 0.012654320987654 0.012342051131355
0.012044817927171
Columns 43 through 48
0.011761561079925 0.011491317671093
0.011233211233211 0.010986442262740 0.010750279955207
0.010524054982818
Columns 49 through 54
0.010307153164296 0.010099009900990
0.009899105273177 0.009706959706960 0.009522130135779
0.009344206591913
Columns 55 through 60
0.009172809172809 0.009007585335019
0.008848207475210 0.008694370763336 0.008545791197835
0.008402203856749
Columns 61 through 66
0.008263361322138 0.008129032258065
0.007999000124984 0.007873062015504 0.007751027598356
0.007632718159034
Columns 67 through 72
0.007517965726921 0.007406612279948
0.007298509018872 0.007193515704154 0.007091500049247
0.006992337164751
Columns 73 through 78
0.006895909048551 0.006802104117540
0.006710816777042 0.006621947024424 0.006535400083787
0.006451086068920
Columns 79 through 84
0.006368919672001 0.006288819875776
0.006210709687192 0.006134515890613 0.006060168818989
0.005987602141448
Columns 85 through 90
0.005916752665979 0.005847560155935
0.005779967159278 0.005713918849512 0.005649362877409
0.005586249232658
Columns 91 through 96
0.005524530114694 0.005464159811986
0.005405094589155 0.005347292581335 0.005290713695233
0.005235319516408
Columns 97 through 100
0.005181073222310 0.005127939500673
0.005075884472869 0.005024875621891
>>