Anda di halaman 1dari 20

# TUGAS I

MATLAB
PIRANTI LUNAK TELEKOMUNIKASI

## JURUSAN TEKNIK ELEKTRO

FAKULTAS TEKNIK UNIVERSITAS UDAYANA
DENPASAR
2016
P2.3

>> 2^5/(2^6-1)

ans =
0.5079

>> exp (4)

ans =
54.5982

>> log (exp(4))

ans =
4

## d. Coding Program di mfile

>>log10(exp(4))
hasil di command window
ans =
1.7372

## e. Coding Program di mfile

>> exp(pi*sqrt(121))

ans =
1.0189e+015

## f. Coding Program di mfile

cos(pi/4)+sin(pi/3)^2

ans =
1.4571

## g. Coding Program di mfile

>> log(exp(3))+log10(exp(1)

ans =

3.434

## h. Coding Program di mfile

area = pi*(pi/3)^2
hasil di command window
area =
3.4451
P2.4

## a. Coding Program di mfile

solve('2^x=7','x')

ans =
log(2, 7)

## b. Coding Program di mfile

solve('log(x)=3')

ans =

exp(3)

>> exp(3)

ans =
20.0855

## c. Coding Program di mfile

solve('exp(x)=10')
hasil di command window
ans =
log(10)

>> log(10)

ans =
2.3026

## d. Coding Program di mfile

>>solve sqrt(3^(1/3)*9^(1/3))=(1/3)^x

## hasil di command window

ans =
-1/2
% program penghitung luas segitiga
% input:(x1,y1), (x2,y2), dan (x3,y3)
e. Coding Program
% rumus di mfile
L = sqrt(s*(s-a)*(s-b)*(s-c))
% rumus s = 1/2*(a+b+c)
% solve('sqrt(2)/6^3=3^x')
k, l,dan m adalah panjang masing2 sisi

## % input titik-titik koordinat

x1 = input('masukkan nilai x1 = ')
hasily1di =command window nilai y1 = ')
input('masukkan
ans =
x2 = input('masukkan nilai x2 = ')
y2 =108*2^(1/2))
-log(3, input('masukkan nilai y2 = ')

## x3 = input('masukkan nilai x3 = ')

y3 = input('masukkan nilai y3 = ')

% menghitung sisi k, l, m
k = sqrt((x1-x2)^2+(y1-y2)^2);
l = sqrt((x2-x3)^2+(y2-y3)^2);
P.2.25
m =Coding Program di mfile
sqrt((x1-x3)^2+(y1-y3)^2);

% menghitung s
s = 1/2*(a+b+c);

## % menghitung luas segitiga

L = sqrt(s*(s-a)*(s-b)*(s-c))
Hasil di command window
input nilai x1 = 2

x1 =
2
input nilai y1 = 2
y1 =
2
input nilai x2 = 4

x2 =
4
input nilai y2 = 2
y2 =
2
input nilai x3 = 2
x3 =
2
input nilai y3 = 2
y3 =
2
L=
3.5000

2.26

## a. Coding Program di mfile

% program penghitung panjang slope
% rumus panjang slope=(Y(2)-Y(1))/(X(2)-X(1))

P1=[5 -1];
P2=[3 2];

X=[P1(1),P2(1)];
Y=[P1(2),P2(2)];

Slope = (Y(2)-Y(1))/(X(2)-X(1));

## Hasil di command window

total panjang slope =-1.5.

## % program penghitung panjang slope

% rumus
b. Coding panjang
Program slope=(Y(2)-Y(1))/(X(2)-X(1))
di mfile
P1=[8 1];
P2=[9 0];

X=[P1(1),P2(1)];
Y=[P1(2),P2(2)];

Slope = (Y(2)-Y(1))/(X(2)-X(1));

## disp(['total panjang slope =' num2str(Slope) '.']);

Hasil di command window
total panjang slope =-1.

## c. Coding Program di mfile

% program penghitung panjang slope
% rumus panjang slope=(Y(2)-Y(1))/(X(2)-X(1))

P1=[5 3];
P2=[-1 7];

X=[P1(1),P2(1)];
Y=[P1(2),P2(2)];

Slope = (Y(2)-Y(1))/(X(2)-X(1));

## % program penghitung populasi

% dengan persamaan= 227*exp(0.007*n)
% diketahuik=30,l=40,m=70
2.37 k= 30;
Coding Program di mfile
l= 40;
m= 70;

P(k)=227*exp(0.007*k);
P(l)=227*exp(0.007*l);
P(m)=227*exp(0.007*m);

## disp(['P(k) =' num2str(P(a)) '.']);

disp(['P(l) =' num2str(P(b)) '.']);
disp(['P(m) =' num2str(P(c)) '.']);
Hasil di command window
P(k) =280.0449.
P(l) =300.3505.
P(m) =370.5358.

## 3.2 Let x=1:10, evaluate the following commands :

a. x-x
b. x.^x
c. x.*x
d. x*x
e. x*x
f. x.\x
g. x./x
h. x=x

>> x=1:10
x=
1 2 3 4 5 6 7 8 9 10
a. >> x-x
ans =
0 0 0 0 0 0 0 0 0 0

b. >> x.^x
ans =
1.0e+10 *
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0001
0.0017 0.0387 1.0000

c. >> x.*x
ans =
1 4 9 16 25 36 49 64 81 100
d. >> x'*x
ans =
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10 12 14 16 18 20
3 6 9 12 15 18 21 24 27 30
4 8 12 16 20 24 28 32 36 40
5 10 15 20 25 30 35 40 45 50
6 12 18 24 30 36 42 48 54 60
7 14 21 28 35 42 49 56 63 70
8 16 24 32 40 48 56 64 72 80
9 18 27 36 45 54 63 72 81 90
10 20 30 40 50 60 70 80 90 100
e. >> x.\x
ans =
1 1 1 1 1 1 1 1 1 1

f. >> x./x
ans =
1 1 1 1 1 1 1 1 1 1

g. >> x='x'
x=
x
h. >> x='x'
x =

K= x

1 0
R3.63 Coding Program di mfile
0 1
K=[1 0; 0 1]
K'*K=
ans
K*K'
1
inv(K) 0
orth(K)
0 1
ans =
1 0
Hasil di command window
0 1
ans =
1 0
0 1
ans =
1 0
1 1
>> K=[cos(0) -sin(0); sin(0) cos(0)]
K=
1 0
0 1

>> K'
ans =
1 0
0 1

>> inv(K)
ans =
1 0
0 1
R.3.64

ans =
1 0

0 1

## >> L=[cosd(180) -sind(180); sind(180) cosd(180)]

L=
-1 0
0 -1

>> L'
ans =
-1 0
0 -1
>> M=[cosd(360) -sind(360); sind(360) cosd(360)]
M=
1 0
0 1

>> M'
ans =
1 0
0 1

>> inv(M)
ans =
1 0
0 1

>> orth(M)
ans =
1 0
0 1
>> N=[cosd(540) -sind(540); sind(540) cosd(540)]
N=
-1 0
0 -1

>> N'
ans =
-1 0
0 -1

>> inv(N)
ans =
-1 0
0 -1

>> orth(N)
ans =
1 0
0 1
>> O=[cosd(720) -sind(720); sind(720) cosd(720)]
O=
1 0
0 1
>> 0'
ans =
1 0
0 1

>> inv(O)
ans =
1 0
0 1

>> orth(O)
ans =
1 0
1 1
5.18 Coding Program di mfile
% plot=y = x.^3 + 4*x.^2 - x - 4
% domain= -5x-2
n = [3 4 5 6 7 101];
style = {'b-','r-','g-','y-','m-','c-'};

for i = 1:numel(n)
x = linspace(-5,2,n(i));

y = x.^3 + 4*x.^2 - x - 4;

plot(x,y,char(style(i)))
hold on
end

xlabel('x')
ylabel('y = x^3+4x^2-x-4')
legend('3 point',' 4 point', '5 point', '6 point', '7 point',
'101 point','Location', 'SouthEast')
title('plot');
Run program
R 5.19 Coding Program di mfile

x1=linspace(0,2,5);
x2=linspace(0,2,10);
x3=linspace(0,2,15);
x4=linspace(0,2,20);

k=x1*pi;
l=x2*pi;
m=x3*pi;
n=x4*pi;

y1=1.5*cos(2*k)
y2=1.5*cos(2*l)
y3=1.5*cos(2*m)
y4=1.5*cos(2*n)

plot(x1,y1,'b:h',x2,y2,'m-d',x3,y3,'g--p',x4,y4,'y-s')
title {'Grafik R5.19'}

Run program
x = -2*pi:0.4:2*pi;

y1 = sin(x);

y2 = (sin(x).^2)./x;

plot(x,y1,'*:')

hold on

plot(x,y2,'s--')

## 5.73 coding program di mfile

xlabel('x')
ylabel('y')
legend('y_1','y_2')
box on
grid on
title('Piranti Lunak ')
text(-3.5,0.3,'\leftarrow y_1')
text(-2,-0.4,'\leftarrow y_2')
Run program

%[y1di=mfile
R5.46 coding program 10 sin(x)] versus x and [y2 = 2cos(x) + noise(x)]
versus x using the same y scale

x = linspace(0,3*pi,100);
y1 = 10*sin(x);
y2 = 2*cos(x) + rand(1,100);
plot(x,y1,x,y2)
title('plot using same y-scale')
Run program

%[y1 program
coding = 10 sin(x)]
di mfileversus x and [y2 = 2cos(x) + noise(x)]
versus x using different y scale
x = linspace(0,3*pi,100);
y1 = 10*sin(x);
y2 = 2*cos(x) + rand(1,100);
plotyy(x,y1,x,y2)
title('plot using different y-scale')
Run program

### Dapatkan aplikasi gratis kami

Hak cipta © 2021 Scribd Inc.