,
|
+
=
6 3 ,
2
1
2
1
3 1 , 2
1 2 , 3
x untuk x
x untuk
x untuk x
x f
Jawab :
Buatlah fungsi dan simpan dengan nama Fungsi
function [x]= Fungsi (x);
if x>=-2 & x<1
f= -x+3;
fprintf ('nilai f(x) adalah = %d \n',f);
elseif x>=1 & x<3
f= 2;
fprintf ('nilai f(x) adalah = %d \n',f);
elseif x>=3 & x<=6
f= -1/2*x-1/2;
fprintf ('nilai f(x) adalah = %d \n',f);
else
fprintf('tidak ada definisi f(x) untuk x = %d \n',x);
end;
outputnya sbb :
Fungsi(4)
nilai f(x) adalah = -2.500000e+000
ans =
4
Fungsi(5)
nilai f(x) adalah = -3
ans =
5
3) Buatlah m.file untuk membuat grafik :
a.
)
)
subplot ah per dengan
x untuk x x x x g
x x x x f
int
20 20 3 3 2
1 4 3
2 4 5
2 3
+ + =
+ + =
Jawab:
Buat m.file dan simpan dengan nama3a
clear;clc;
y=-20:0.1:20
f=y.^3- 3*y.^2 +4*y+1;
g=2*y.^5+3*y.^4-y.^2+3;
subplot(2,2,1)
plot(f,y);title('f(x)');
subplot(2,2,2)
plot(g,y);title('g(x)');
outputnya adalah sbb:
b. )
,
|
+
=
15 4 ,
1
3
4 0 , 1
2
x untuk
x
x untuk x
x f
c.
|
,
|
=
=
t t y
t untuk t t t x
80 sin sin 2
2 0 , sin 80 cos cos T
d. sendiri n disesuaika gambar bidang y x z , 25
2 2
=
Jawab:
Buat m.file dan simpan dengan nama3d
clear;clc;
[x,y]=meshgrid (1:.1:5, 8:.1:20);
z = 25 - 2*x.^2 - y.^2;
mesh(z,x,y);
outputnya adalah sbb: