SCRIPT No.
%MEMBUAT GRAFIK 3D
clear
clc
disp('Nama :Bergas Samudera Perkasa')
disp('NRP :04111740000085')
disp('Hati 3D')
%MEMASUKKAN PERSAMAAN
%3D Heart
[y,x,z] = ndgrid(linspace(-2,2,100),linspace(-2,2,100),linspace(-2,2,100));
f = (x.^2+9/4*y.^2+z.^2-1).^3-x.^2.*z.^3-9/80*y.^2.*z.^3;
colormap hot
cla
isosurface(x,y,z,f,.0);
view(3);
camlight
axis on
text(0,0,-1.5,'ICE COLD','Color','blue','FontSize',20,'Rotation',+15)
%Arrow
hold on
quiversensorx = quiver3(-1.25,0.75,-0.75,2.25,-1.75,1.75);
step = 0.05;
[X,Y] = meshgrid(-1:0.25:1);
hold on
set(quiversensorx, 'Color', 'blue');
set(quiversensorx, 'LineWidth', 3);
HASIL
Nama :Bergas Samudera Perkasa
NRP :04111740000085
Hati 3D
>>
SCRIPT No. 2
%MENGHITUNG PERSAMAAN POLINOMIAL
clear clc
%Memasukkan 3 digit NRP terakhir
c= input ('Masukkan 3 digit NRP terakhir =');
disp(' Matriks X'); x0=c*1;
x1=c*2; x2=c*3; x3=c*4; x4=c*5; x5=c*6;
X=[x0;x1;x2;x3;x4;x5]
disp('Matriks Y'); Y=[0;2;3;2;1;3];
Matrix_Y=c*[0;2;3;2;1;3]
disp('Diketahui Persamaan Polinomial Y --> Matrix Y= Pol(X)x A');
disp('Y=a0+a1x+a2x.^2+a3x.^3+a4x.^4+a5x.^5');
disp('a. Buat Matriks Y dan Poly X');
%nilai polinomial x
polyx0 =[1 x0 x0.^2 x0.^3 x0.^4 x0.^5];
polyx1 =[1 x1 x1.^2 x1.^3 x1.^4 x1.^5];
polyx2 =[1 x2 x2.^2 x2.^3 x2.^4 x2.^5];
polyx3 =[1 x3 x3.^2 x3.^3 x3.^4 x3.^5];
polyx4 =[1 x4 x4.^2 x4.^3 x4.^4 x4.^5];
polyx5 =[1 x5 x5.^2 x5.^3 x5.^4 x5.^5];
polyX =[polyx0;polyx1;polyx2;polyx3;polyx4;polyx5]
Matrix_Y=c*[0;2;3;2;1;3]
disp('b. Invers Matrix poly X'); invX= inv(polyX)
disp('c. Hitung Matrix A'); A=polyX\Matrix_Y
disp('Defenisikan fungsi Y')
a0=A(1,1);
a1=A(2,1);
a2=A(3,1);
a3=A(4,1);
a4=A(5,1);
a5=A(6,1);
disp('d. hitung persamaan Y jika X diubah')
disp('dengan koordinat Y yang sama, diketahui:')
X2=c*[0;1.5;2.5;3.5;4.5;5.5]
x6=X2(1,1);
x7=X2(2,1);
x8=X2(3,1);
x9=X2(4,1);
x10=X2(5,1);
x11=X2(6,1);
%poly X2
polyx6 = [1 x6 x6.^2 x6.^3 x6.^4 x6.^5];
polyx7 = [1 x7 x7.^2 x7.^3 x7.^4 x7.^5];
polyx8 = [1 x8 x8.^2 x8.^3 x8.^4 x8.^5];
polyx9 = [1 x9 x9.^2 x9.^3 x9.^4 x9.^5];
polyx10 = [1 x10 x10.^2 x10.^3 x10.^4 x10.^5];
polyx11 = [1 x11 x11.^2 x11.^3 x11.^4 x11.^5];
polyX2 = [polyx6;polyx7;polyx8;polyx9;polyx10;polyx11]
Matrix_Y=c.*Y
A2=polyX2\Matrix_Y
disp('Defenisikan fungsi Y')
a6=A2(1,1);
a7=A2(2,1);
a8=A2(3,1);
a9=A2(4,1);
a10=A2(5,1);
a11=A2(6,1);
disp('[Link] Y dan Y2')
disp('didapatkan :')
fprintf ('Y=(%.4f) +(%.4f x) +(%.4f x^2) +(%.4f x^3) +(%.4f x^4) +(%.4f
x^5)\n', a0,a1,a2,a3,a4,a5')
fprintf ('Y2=(%.4f) +(%.4f x) +(%.4f x^2) +(%.4f x^3) +(%.4f x^4) +(%.4f
x^5)\n', a6,a7,a8,a9,a10,a11')
x=-1[Link];
y=a0+(a1.*x)+(a2.*x.^2)+(a3.*x.^3)+(a4.*x.^4)+(a5.*x.^5);
y2=a6+(a7.*x)+(a8.*x.^2)+(a9.*x.^3)+(a10.*x.^4)+(a11.*x.^5);
plot(x,y)
legend('y')
xlabel('x=-10000\leq x\leq 10000')
ylabel('y')
title('Perbandingan y dan y2')
hold on
plot(x,y2)
legend('y','y2')
hold off
HASIL
>> nomor2
Masukkan 3 digit NRP terakhir = 085
Matriks X
X=
85
170
255
340
425
510
Matriks Y
Matrix_Y =
170
255
170
85
255
Diketahui Persamaan Polinomial Y --> Matrix Y= Pol(X)x A
Y=a0+a1x+a2x.^2+a3x.^3+a4x.^4+a5x.^5
a. Buat Matriks Y dan Poly X
polyX =
1.0e+13 *
0.0000 0.0000 0.0000 0.0000 0.0000 0.0004
0.0000 0.0000 0.0000 0.0000 0.0001 0.0142
0.0000 0.0000 0.0000 0.0000 0.0004 0.1078
0.0000 0.0000 0.0000 0.0000 0.0013 0.4544
0.0000 0.0000 0.0000 0.0000 0.0033 1.3866
0.0000 0.0000 0.0000 0.0000 0.0068 3.4503
Matrix_Y =
170
255
170
85
255
b. Invers Matrix poly X
invX =
6.0000 -15.0000 20.0000 -15.0000 6.0000 -1.0000
-0.1024 0.3441 -0.4980 0.3882 -0.1588 0.0269
0.0007 -0.0027 0.0043 -0.0035 0.0015 -0.0003
-0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000
0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000
-0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000
c. Hitung Matrix A
A=
255.0000
-9.1500
0.1015
-0.0004
0.0000
-0.0000
Defenisikan fungsi Y
d. hitung persamaan Y jika X diubah
dengan koordinat Y yang sama, diketahui:
X2 =
127.5000
212.5000
297.5000
382.5000
467.5000
polyX2 =
1.0e+13 *
0.0000 0 0 0 0 0
0.0000 0.0000 0.0000 0.0000 0.0000 0.0034
0.0000 0.0000 0.0000 0.0000 0.0002 0.0433
0.0000 0.0000 0.0000 0.0000 0.0008 0.2330
0.0000 0.0000 0.0000 0.0000 0.0021 0.8188
0.0000 0.0000 0.0000 0.0000 0.0048 2.2331
Matrix_Y =
170
255
170
85
255
A2 =
-2.0286
0.0544
-0.0003
0.0000
-0.0000
Defenisikan fungsi Y
[Link] Y dan Y2
didapatkan :
Y=(255.0000) +(-9.1500 x) +(0.1015 x^2) +(-0.0004 x^3) +(0.0000 x^4) +(-0.0000 x^5)
Y2=(0.0000) +(-2.0286 x) +(0.0544 x^2) +(-0.0003 x^3) +(0.0000 x^4) +(-0.0000 x^5)
>>