Professional Documents
Culture Documents
x =
Y = sin(x)
Y =
sin(x)
y =(2*x^3)^-1
y =
1/(2*x^3)
syms a b c x
f =a*x^2+b*x^2
f =
a*x^2 + b*x^2
g = diff(f)
g =
2*a*x + 2*b*x
g_prime = diff(sqrt(3*x^2+2*x^5))
g_prime =
w = sym('w')
w =
z = 3*cos(w)/sin(2*w/(w+1))
z =
(3*cos(w))/sin((2*w)/(w + 1))
t = sym('t')
t =
t
A = [3*sin(t) -cos(t^2); cos(2*t) -sin(t)]
A =
[ 3*sin(t), -cos(t^2)]
[ cos(2*t), -sin(t)]
ff = 2 x2 + 3 x - 5
ff = 2 x2 + 3 x - 5
|
{#Error: Unexpected MATLAB expression.
}#
ff = 2*x^2 + 3*x - 5
ff =
2*x^2 + 3*x - 5
gg = x^2 - x + 7
gg =
x^2 - x + 7
a = 1
a =
b = 3/2
b =
1.5000
fg = ff + gg
fg =
3*x^2 + 2*x + 2
gf = ff - gg
gf =
x^2 + 4*x - 12
ffg = ff .* gg
ffg =
ffg = ff * gg
ffg =
(x^2 - x + 7)*(2*x^2 + 3*x - 5)
fgg = ff / gg
fgg =
ffx = ff^(3*x)
ffx =
f = sin (a - x)
f =
-sin(x - 1)
g = sin (b x^2)
g = sin (b x^2)
|
{#Error: Unexpected MATLAB expression.
}#
g = sin (b*x^2)
g =
sin((3*x^2)/2)
clear all
syms a b c d x s
f = a*x^3 + x^2 + b*x - c
f =
df = diff(f)
df =
3*a*x^2 + 2*x + b
dfa = diff(f,a)
dfa =
x^3
df2 = diff(f,2)
df2 =
6*a*x + 2
dfa2 =
t=sym('t')
t =
F=[3*sin(t)-cos(t^2); cos(2*t)-sin(t)]
F =
3*sin(t) - cos(t^2)
cos(2*t) - sin(t)
dF = diff(F)
dF =
3*cos(t) + 2*t*sin(t^2)
- 2*sin(2*t) - cos(t)
dF2 = diff(F,2)
dF2 =
Iff = int(f)
Iff =
Ifab =
IF = int(F)
IF =
- 3*cos(t) - (2^(1/2)*pi^(1/2)*fresnelC((2^(1/2)*t)/pi^(1/2)))/2
(2*(tan(t/2) + tan(t/2)^2 - tan(t/2)^3 + 1))/(tan(t/2)^2 + 1)^2
IFab =
3 - (2^(1/2)*pi^(1/2)*(fresnelC(2^(1/2)*pi^(1/2)) -
fresnelC((2^(1/2)*pi^(1/2))/2)))/2
-1
for n=1 : 10
x(n)=sin(n*pi/10)
end
x =
0.3090
x =
0.3090 0.5878
x =
x =
Columns 1 through 3
Column 4
0.9511
x =
Columns 1 through 3
Columns 4 through 5
0.9511 1.0000
x =
Columns 1 through 3
x =
Columns 1 through 3
Columns 4 through 6
Column 7
0.8090
x =
Columns 1 through 3
Columns 4 through 6
Columns 7 through 8
0.8090 0.5878
x =
Columns 1 through 3
Columns 4 through 6
Columns 7 through 9
x =
Columns 1 through 3
Columns 4 through 6
Column 10
0.0000
data=[3 9 45 6; 7 16 -1 5]
data =
3 9 45 6
7 16 -1 5
for n=data
x=n(1)-n(2)
end
x =
-4
x =
-7
x =
46
x =
for n=1 : 5
for m=5:-1 : 1
A(n,m)=n^2+m^2;
end
disp(n)
end
1
zeros(1, 10);
for n=1 : 10
x(n)=sin(n*pi/10);
end
zeros(1, 10)
ans =
Columns 1 through 6
0 0 0 0 0 0
Columns 7 through 10
0 0 0 0
for n=1 : 10
x(n)=sin(n*pi/10);
end
for n=1 : 10
x(n)=sin(n*pi/10)
end
x =
Columns 1 through 3
Columns 4 through 6
Columns 7 through 9
Column 10
0.0000
x =
Columns 1 through 3
Columns 4 through 6
Columns 7 through 9
Column 10
0.0000
x =
Columns 1 through 3
Columns 4 through 6
Columns 7 through 9
Column 10
0.0000
x =
Columns 1 through 3
Columns 4 through 6
Columns 7 through 9
Column 10
0.0000
x =
Columns 1 through 3
Columns 4 through 6
Columns 7 through 9
Column 10
0.0000
x =
Columns 1 through 3
0.3090 0.5878 0.8090
Columns 4 through 6
Columns 7 through 9
Column 10
0.0000
x =
Columns 1 through 3
Columns 4 through 6
Columns 7 through 9
Column 10
0.0000
x =
Columns 1 through 3
Columns 4 through 6
Columns 7 through 9
Column 10
0.0000
x =
Columns 1 through 3
Columns 7 through 9
Column 10
0.0000
x =
Columns 1 through 3
Columns 4 through 6
Columns 7 through 9
Column 10
0.0000
% Kesimpulan : For loops digunakan untuk mengulang perintah yang sama untuk seluruh
rentang yang diperlukan. Perintah For harus diakhir end agar memperoleh hasil dan
tidak menggantung
num=0; EPS=1;
while (1+EPS)>1
EPS=EPS/2
num=num+1
end
EPS =
0.5000
num =
EPS =
0.2500
num =
2
EPS =
0.1250
num =
EPS =
0.0625
num =
EPS =
0.0313
num =
EPS =
0.0156
num =
EPS =
0.0078
num =
EPS =
0.0039
num =
8
EPS =
0.0020
num =
EPS =
9.7656e-04
num =
10
EPS =
4.8828e-04
num =
11
EPS =
2.4414e-04
num =
12
EPS =
1.2207e-04
num =
13
EPS =
6.1035e-05
num =
14
EPS =
3.0518e-05
num =
15
EPS =
1.5259e-05
num =
16
EPS =
7.6294e-06
num =
17
EPS =
3.8147e-06
num =
18
EPS =
1.9073e-06
num =
19
EPS =
9.5367e-07
num =
20
EPS =
4.7684e-07
num =
21
EPS =
2.3842e-07
num =
22
EPS =
1.1921e-07
num =
23
EPS =
5.9605e-08
num =
24
EPS =
2.9802e-08
num =
25
EPS =
1.4901e-08
num =
26
EPS =
7.4506e-09
num =
27
EPS =
3.7253e-09
num =
28
EPS =
1.8626e-09
num =
29
EPS =
9.3132e-10
num =
30
EPS =
4.6566e-10
num =
31
EPS =
2.3283e-10
num =
32
EPS =
1.1642e-10
num =
33
EPS =
5.8208e-11
num =
34
EPS =
2.9104e-11
num =
35
EPS =
1.4552e-11
num =
36
EPS =
7.2760e-12
num =
37
EPS =
3.6380e-12
num =
38
EPS =
1.8190e-12
num =
39
EPS =
9.0949e-13
num =
40
EPS =
4.5475e-13
num =
41
EPS =
2.2737e-13
num =
42
EPS =
1.1369e-13
num =
43
EPS =
5.6843e-14
num =
44
EPS =
2.8422e-14
num =
45
EPS =
1.4211e-14
num =
46
EPS =
7.1054e-15
num =
47
EPS =
3.5527e-15
num =
48
EPS =
1.7764e-15
num =
49
EPS =
8.8818e-16
num =
50
EPS =
4.4409e-16
num =
51
EPS =
2.2204e-16
num =
52
EPS =
1.1102e-16
num =
53
EPS=2*EPS
EPS =
2.2204e-16
% Kesimpulan : While Loops digunakan ketika ada persyaratan dalam suatu soal atau
perintah untuk memenuhi suatu kriteria seperti kurang dari (<) atau lebih dari (>)
dan persyaratan lainnya.
apples=10
apples =
10
cost=apples*25
cost =
250
if apples>5
cost=(1-20/100)*cost
end
cost =
200
cost
cost =
200
EPS=1
EPS =
for num=1:1000
EPS=EPS/2;
if (1+EPS)<=1
EPS=EPS*2
break
end
end
EPS =
2.2204e-16
x=2.7
x =
2.7000
units= 'cm';
switch units
case {'inch' , 'in'}
y=x*2.54;
case {'feet' , 'ft'}
y=x*2.54*12;
case {'meter' , 'm'}
y=x/100;
case {'millimeter' , 'mm'}
y=x*10;
case {'centimeter' , 'cm'}
y=x;
otherwise
disp(['Unknown Units: ' units])
y=nan;
end
% Kesimpulan : Switch digunakan untuk merubah atau mengganti satuan. Namun saya
belum paham untuk penggunaannya Bapak. Mengapa tanda panahnya hilang sendiri dan
eror kebawahnya.