0% found this document useful (0 votes)
39 views3 pages

Lampiran 1. Fungsi Jarak Function Jarak (x1, x2, Y1, Y2)

This document contains code for calculating distances and derivatives in VBA. It includes a function to calculate the distance between two points based on their x and y coordinates. It then uses this function in several button click events to calculate the 1st, 2nd, 3rd derivatives of data by taking the difference between values and dividing by the distance. It loads data from a text file into MATLAB to plot the 3rd derivative versus x and y coordinates.

Uploaded by

Obedh Sidabutar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views3 pages

Lampiran 1. Fungsi Jarak Function Jarak (x1, x2, Y1, Y2)

This document contains code for calculating distances and derivatives in VBA. It includes a function to calculate the distance between two points based on their x and y coordinates. It then uses this function in several button click events to calculate the 1st, 2nd, 3rd derivatives of data by taking the difference between values and dividing by the distance. It loads data from a text file into MATLAB to plot the 3rd derivative versus x and y coordinates.

Uploaded by

Obedh Sidabutar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Lampiran 1.

Fungsi Jarak Function jarak(x1, x2, y1, y2)

jarak = (((x1 - x2) ^ 2) + ((y1 - y2) ^ 2)) ^ 0.5

End Function

Private Sub CommandButton1_Click() While Cells(4

+ i, 1) <> "" x1 = Cells(4 + i, 1) * 110900 x2 =

Cells(5 + i, 1) * 110900 y1 = Cells(4 + i, 2) * 111322

y2 = Cells(5 + i, 2) * 111322

Cells(4, 4) = 0

Cells(5 + i, 4) = Round(jarak(x1, x2, y1, y2), 4) i = i + 1

Wend

End Sub

Lampiran 2. Turunan Pertama

Private Sub CommandButton2_Click() While Cells(4

+ i, 1) <> "" z1 = Cells(4 + i, 3) z2 = Cells(5 + i, 3) s1

= Cells(5 + i, 4)

Cells(4, 5) = 0

Cells(5 + i, 5) = Round(((z2 - z1) / s1), 4) i = i + 1


Wend

End Sub

Lampiran 3. Turunan Kedua

Private Sub CommandButton3_Click() While Cells(5

+ i, 1) <> "" z1 = Cells(5 + i, 5) z2 = Cells(6 + i, 5) s1

= Cells(6 + i, 4) Cells(4, 6) = 0

Cells(5, 6) = 0

Cells(6 + i, 6) = Round(((z2 - z1) / s1), 7) i = i + 1

Wend

End Sub

Lampiran 4. Turunan Ketiga

Private Sub CommandButton4_Click() While Cells(5

+ i, 1) <> "" z1 = Cells(6 + i, 6) z2 = Cells(7 + i, 6)

s1 = Cells(7 + i, 4) Cells(4, 7) = 0

Cells(5, 7) = 0

Cells(6, 7) = 0
Cells(7 + i, 7) = Round(((z2 - z1) / s1), 9) i = i + 1

Wend

End Sub

Lampiran 5. Syntax Matlab

d=load('FOS.txt');

%e=xlsread('gradient.xls'); %g=e(:,3);

fos=d(:,3); x=d(:,2); %l=x'; y=d(:,1);

plot3(x,y,fos)

You might also like