SORU 1
» x=-1:0.1:1;
» sqrt(x)
ans =
Columns 1 through 4
0+ 1.0000i 0+ 0.9487i 0+ 0.8944i 0+ 0.8367i
Columns 5 through 8
0+ 0.7746i 0+ 0.7071i 0+ 0.6325i 0+ 0.5477i
Columns 9 through 12
0+ 0.4472i 0+ 0.3162i 0 0.3162
Columns 13 through 16
0.4472 0.5477 0.6325 0.7071
Columns 17 through 20
0.7746 0.8367 0.8944 0.9487
Column 21
1.0000
» cos(x)
ans =
Columns 1 through 7
0.5403 0.6216 0.6967 0.7648 0.8253 0.8776 0.9211
Columns 8 through 14
0.9553 0.9801 0.9950 1.0000 0.9950 0.9801 0.9553
Columns 15 through 21
0.9211 0.8776 0.8253 0.7648 0.6967 0.6216 0.5403
» sin(x)
ans =
Columns 1 through 7
-0.8415 -0.7833 -0.7174 -0.6442 -0.5646 -0.4794 -0.3894
Columns 8 through 14
-0.2955 -0.1987 -0.0998 0 0.0998 0.1987 0.2955
Columns 15 through 21
0.3894 0.4794 0.5646 0.6442 0.7174 0.7833 0.8415
» x.^2
ans =
Columns 1 through 7
1.0000 0.8100 0.6400 0.4900 0.3600 0.2500 0.1600
Columns 8 through 14
0.0900 0.0400 0.0100 0 0.0100 0.0400 0.0900
Columns 15 through 21
0.1600 0.2500 0.3600 0.4900 0.6400 0.8100 1.0000
» plot(x,sin(x.^3))
» plot(x,cos(x.^4))
» x=[2 3 4 5]
x =
2 3 4 5
» y=-1:1:2
y =
-1 0 1 2
» x.^y
ans =
0.5000 1.0000 4.0000 25.0000
» x.*y
ans =
-2 0 4 10
» x./y
Warning: Divide by zero.
ans =
-2.0000 Inf 4.0000 2.5000
SORU 2
» a=[1 5 8;84 81 7;12 34 71]
a =
1 5 8
84 81 7
12 34 71
» a(1,1)
ans =
1
» a(1,2)
ans =
5
» a(1:2,:)
ans =
1 5 8
84 81 7
» a(:,1)
ans =
1
84
12
» a(:,2:3)
ans =
5 8
81 7
34 71
» x=1:1:10
x =
1 2 3 4 5 6 7 8 9 10
» z=rand(10)
z =
Columns 1 through 7
0.9501 0.6154 0.0579 0.0153 0.8381 0.1934 0.4966
0.2311 0.7919 0.3529 0.7468 0.0196 0.6822 0.8998
0.6068 0.9218 0.8132 0.4451 0.6813 0.3028 0.8216
0.4860 0.7382 0.0099 0.9318 0.3795 0.5417 0.6449
0.8913 0.1763 0.1389 0.4660 0.8318 0.1509 0.8180
0.7621 0.4057 0.2028 0.4186 0.5028 0.6979 0.6602
0.4565 0.9355 0.1987 0.8462 0.7095 0.3784 0.3420
0.0185 0.9169 0.6038 0.5252 0.4289 0.8600 0.2897
0.8214 0.4103 0.2722 0.2026 0.3046 0.8537 0.3412
0.4447 0.8936 0.1988 0.6721 0.1897 0.5936 0.5341
Columns 8 through 10
0.7271 0.7948 0.1365
0.3093 0.9568 0.0118
0.8385 0.5226 0.8939
0.5681 0.8801 0.1991
0.3704 0.1730 0.2987
0.7027 0.9797 0.6614
0.5466 0.2714 0.2844
0.4449 0.2523 0.4692
0.6946 0.8757 0.0648
0.6213 0.7373 0.9883
» y=[z;x];
» y=[z;x]
y =
Columns 1 through 7
0.9501 0.6154 0.0579 0.0153 0.8381 0.1934 0.4966
0.2311 0.7919 0.3529 0.7468 0.0196 0.6822 0.8998
0.6068 0.9218 0.8132 0.4451 0.6813 0.3028 0.8216
0.4860 0.7382 0.0099 0.9318 0.3795 0.5417 0.6449
0.8913 0.1763 0.1389 0.4660 0.8318 0.1509 0.8180
0.7621 0.4057 0.2028 0.4186 0.5028 0.6979 0.6602
0.4565 0.9355 0.1987 0.8462 0.7095 0.3784 0.3420
0.0185 0.9169 0.6038 0.5252 0.4289 0.8600 0.2897
0.8214 0.4103 0.2722 0.2026 0.3046 0.8537 0.3412
0.4447 0.8936 0.1988 0.6721 0.1897 0.5936 0.5341
1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000
Columns 8 through 10
0.7271 0.7948 0.1365
0.3093 0.9568 0.0118
0.8385 0.5226 0.8939
0.5681 0.8801 0.1991
0.3704 0.1730 0.2987
0.7027 0.9797 0.6614
0.5466 0.2714 0.2844
0.4449 0.2523 0.4692
0.6946 0.8757 0.0648
0.6213 0.7373 0.9883
8.0000 9.0000 10.0000
» c=rand(4)
c =
0.5828 0.4329 0.5298 0.7833
0.4235 0.2259 0.6405 0.6808
0.5155 0.5798 0.2091 0.4611
0.3340 0.7604 0.3798 0.5678
» e=[c eye(size(c)); eye(size(c)) ones(size(c))]
e =
Columns 1 through 7
0.5828 0.4329 0.5298 0.7833 1.0000 0 0
0.4235 0.2259 0.6405 0.6808 0 1.0000 0
0.5155 0.5798 0.2091 0.4611 0 0 1.0000
0.3340 0.7604 0.3798 0.5678 0 0 0
1.0000 0 0 0 1.0000 1.0000 1.0000
0 1.0000 0 0 1.0000 1.0000 1.0000
0 0 1.0000 0 1.0000 1.0000 1.0000
0 0 0 1.0000 1.0000 1.0000 1.0000
Column 8
0
0
0
1.0000
1.0000
1.0000
1.0000
1.0000
» d=sqrt(c)
d =
0.7634 0.6580 0.7279 0.8851
0.6508 0.4753 0.8003 0.8251
0.7180 0.7615 0.4572 0.6790
0.5779 0.8720 0.6163 0.7535
» t1=d*d
t1 =
2.0450 2.1411 1.9605 2.3798
1.8576 1.9830 1.7286 2.1334
1.7643 1.7746 1.7596 2.0859
1.8866 1.9211 1.8647 2.2173
» t2=d.*d
t2 =
0.5828 0.4329 0.5298 0.7833
0.4235 0.2259 0.6405 0.6808
0.5155 0.5798 0.2091 0.4611
0.3340 0.7604 0.3798 0.5678
SORU 3
» a=[1 2 3 4;5 6 7 8;6 5 4 3;4 5 6 7 ]
a =
1 2 3 4
5 6 7 8
6 5 4 3
4 5 6 7
» sum(a(1,:))
ans =
10
» sum(a(:,2))
ans =
18
SORU 4
» a=[2 1 5;2 2 3;1 3 3]
a =
2 1 5
2 2 3
1 3 3
» b=[5;7;6]
b =
5
7
6
» x=inv(a)*b
x =
2.4545
1.4545
-0.2727
» x=a\b
x =
2.4545
1.4545
-0.2727
SORU 5
» disp('karesel iki matris giriniz')
karesel iki matris giriniz
» a=[1 2;3 4]
a =
1 2
3 4
» b=[3 4;5 6]
b =
3 4
5 6
» a+b
ans =
4 6
8 10
» a-b
ans =
-2 -2
-2 -2
» a*b
ans =
13 16
29 36
» a.*b
ans =
3 8
15 24
SORU 6
» a=rand(4)
a =
0.9501 0.8913 0.8214 0.9218
0.2311 0.7621 0.4447 0.7382
0.6068 0.4565 0.6154 0.1763
0.4860 0.0185 0.7919 0.4057
» b=[rand(1);rand(1);rand(1);rand(1)]
b =
0.9355
0.9169
0.4103
0.8936
» x=a\b
x =
-0.8224
0.0123
1.2599
0.7278
» a*x
ans =
0.9355
0.9169
0.4103
0.8936
SORU 7
» x=-2:0.1:2;
» y1=(x.^2).*cos(x);
» y2=(x.^2).*sin(x);
» fplot('[(x.^2).*cos(x),(x.^2).*sin(x)]',[-2 2 -2 2])
» xlabel('x degerleri')
» ylabel('y degerleri')
» title('iki fonkun grafigi')
»
SORU 8
» clear all
» x=-4: 0.02:4;
» y1=cos(x);
» y2=cos(x.^3);
» plot(x,y1);
» plot(x,y2);
» xlabel('x degerlerı');
» ylabel('y2 degerlerı')
>>title('2.grafık')
» xlabel('x degerlerİ');
» ylabel('y1 degerleri');
tİtle('1.grafik')
SORU 9
x=-2:0.1:2;
» y=exp(-x.^2).*cos(x.*20);
» fplot('exp(-x.^2).*cos(x.*20)',[-2,2]);
» xlabel('x degerleri');
» ylabel('exp degerleri');
» title('fonk grafigi');
» plot(x,y)
» xlabel('x degerleri');
» ylabel('exp degerleri');
» title('fonk grafigi');
»
SORU 10
SORU 11
» clc
»
[x,y]=meshgrid(1.0:0.1:3.0,1.0:0.1:3.0);
»
z=0.5*x.*y.*(x.^2+y.^2);
» figure(1);
» surfl(x,y,z);
» axis([1 3 1 3
100 0])
»
xlabel('x-axis');ylabel('y-axis');zlabel('z-axis');
» figure(2);
»
contour3(x,y,z,15);
» axis([1 3 1 3
100 0])
» xlabel('x-axis');ylabel('y-axis');zlabel('z-axis');
» figure(3);
»
contourf(x,y,z,10)
»
xlabel('x-axis');ylabel('y-axis');
SORU 12
» dif=1;x2=2;
» while dif>0.0005
x1=1/(x2-1);
dif=abs(x2-x1);
x2=x1
end
x2 =
1
Warning: Divide by zero.
x2 =
Inf
x2 =
0
x2 =
-1
x2 =
-0.5000
x2 =
-0.6667
x2 =
-0.6000
x2 =
-0.6250
x2 =
-0.6154
x2 =
-0.6190
x2 =
-0.6176
x2 =
-0.6182
x2 =
-0.6180
»