Anda di halaman 1dari 1

PEMOGRAMAN KOMPUTER

NO 1.
jum=0;
for k=1:20
jum=jum+3*k^2;
end
fprintf('jumlah deret bilangan %6.0f \n',jum)

NO 2
function [v,l]=vl(a,b)
v=1/4*pi^2*(a+b).*(b-a).^2;
l=pi^2*(b.^2-a.^2);
end
>>[V,L]=vl(3,4)

NO 3.
x=input('masukkan nilai x >')
y=input('masukkan nilai y >')
r=sqrt(x^2+y^2);
if x>0
theta=atan(y/x);
else
theta=atan(y/x)+pi;
end
theta=theta*(180/pi);
fprintf ('besar r %6.2f \n',r)
fprintf ('besar sudut theta %6.2f \n',theta)

NO 4
function uas4
[t,y]=ode45(@uget,[0,2],[5,0])
plot(t,y(:,1),t,y(:,2))

function dydt=uget(t,y)
dydt1=y(2);
dydt2=(10/3)*y(2)+(50/3)*y(1)+(6/3)*sin(5*t);
dydt=[dydt1;dydt2]
end
end