Sebuah Catatan Lecek !

Kumpulan Jurnal perjalanan, tips-tips apapun itu. dan catatan-catatan kecil lainya. A Litte works, sebenarnya adalah project terpendam saya. sebuah ide 'cemerlang' untuk menghemat memori. dan jawaban dari petanyaan berulang-ulang yang kerap kali mendatangi saya. *hehehehe*. blog ini nantinya akan berisi tentang hal-hal apa saja yang pernah saya pelajari dan saya anggap akan cukup berguna.

satu lagi, jangan merefer blog ini untuk jurnal ilmiah kalian yahhh.. saya sudah sediakan sumber dari bahan referensi saya supaya lebih lengkap tinjau langsung aja ke-sumbernya

penulis tidak bertanggung jawab atas hal apapun yang akan terjadi setelah pembaca merefer tulisan dari blog ini.

akhir kata..


Selamat Mengubek!


Monday, March 5, 2012

Program Zero Up Crossing

Coming back to the blog and i got a good news for ya'll:  I'm a master student now!! *YAY!* majoring Ocean Engineering in ITB. hahaha! I'm soo excited that finally i can sit in class again working on assignments and worrying the mid test :))  *Ewh~ such a beautiful pain!* 

so today i'm going to post something, that related to my course in ITB. this is my first assignment in my master course: A Zero up crossing program in matlab! . for those who doesn't know what the f* is zero up crossing here's the definition :
 
zero up crossing is one common method that use to define one wave from wave records statistically. in this method a 'wave' is defined as the portion of a record between two successive zero up crossings.

still don't get it? here's the illustration taken from Mandly Hydraulics Laboratory:

zero up crossing wave illustration
image taken from this

so here's the program and the explaination:

1. Loading wave data from excell file:

clc; clear all; close all;
%--------------------------------------------------
% ZERO UP CROSSING PROGRAM
% MEIRITA RAMDHANI
% 25511301
% 2ND ASSIGNMENT OF ADVANCE RANDOM WAVES SUBJECT
% -------------------------------------------------

% 1. LOADING WAVE DATA

filename ='Wave elevation_wt_ meter_ Meulaboh_Feb4.xls';
sheet = 'RawData Wave';
range = 'D4:DP409';    
PAR = xlsread(filename, sheet, range);
dt=0.4;

2. Calculating wave average 

% 2. CALCULATING WAVE AVERAGE
Araw=PAR(:,1);
Abar=sum(Araw)/length(Araw);
Azero=Araw-Abar;


resulting:
the wave data minus its average.



3. Determining the zero up crossing index.
The zero up crossing index is determined by looking at the wave records value sign. after you subtracted your  wave record with its average, you'll get your data reference in y=0. so that, you'll have data which values is negative and positive. from here, you can determine the zero up crossing index. 

in your data, whenever negative values meets positive values then you'll get one zero up crossing wave. the 'one zero up crossing wave'  is define between one 'negative-meet-positiv' and 'next negative-meet-positive'
*ewh.. i'm not really good in explaining this* anyway here's the matlab scipt:

% 3. CALCULATING ZERO UP CROSSING
I1=Azero(1:end-1);
I2=Azero(2:end);

indx=zeros(size(I1));
for i=1:length(indx);
    indx(i)=I1(i)*I2(i); %negativ ketemu positiv
end   

indz=find(indx < 0); %index ZUC & ZDC
indc=zeros(length(indz),1);

indzuc= find(Azero < 0);
zuc=intersect(indz,indzuc);  %index zeroup crossing
izuc=zeros(length(zuc),1);



result:
the wave data and it's zero up crossing index
1.       4. Calculating the Wave height;
     After you got your index, now, its time calculating the wave height between 2 index of zero up crossing that we define in previous. to calculate the wave height, we must subtracting the maximum and minimum values which happen in between 2 zero up crossing index. then you'll get list of wave height. 

     if you sort the wave height from the larger value to the smaller value then you can calculate other waves parameter such as: H1/3, H1/10, Hrms. etc.

%4. CALCULATING WAVE HEIGHT
   w1=zuc(1:end-1)+1;
   w2=zuc(2:end);
  for i=1:length(w1);
    A=max(max(Azero(w1(i):w2(i)))) % maximum wave
    B=min(min(Azero(w1(i):w2(i)))) % minimum wave
    H(i)=A-B   ; % maximum wave height – minimum wave height
  end

%5. SORTING WAVE HEIGHT

nwave=length(H);
swave=sort(H)'; % mengurutkan tinggi gelombang dari yg tinggi ke rendah
swave=flipud(swave);

  Results:
Upper picture is the wave height that is calculated from the zero up crossing .
and the lower picture is after we sort the wave height.



  Oke that's it for today. hope the program will usefull for anyone who need it. next post will be arround FFT something.

  SEE YA!

5 comments:

Yonghyun said...

hi.

My name is Yonghyun JO.

I live in South Korea..

I Kunsan National University in South Korea to attend.

Of Internet search, I accidentally came to your blog.

I would like to have a
((zero-up-cross. M file)) you created.

Please send me an e-mail.

(joyonghyun1@gmail.com)


Please help me........

Anonymous said...

mbaak, ngeplot nya itu gimana yaa? mohon bantuannya yaa.

Unknown said...

nice code mei, kaangge pisan ah :D nuhun

Reza said...

kalo hasil yang keluar kayak gini apa yang salah ya???




??? Attempted to access PAR(:,1); index out of
bounds because size(PAR)=[0,0].

Unknown said...

Hello!!! I am Alejandro Paladio
I'm triyin to do the same in VBA, I am a master student from méxico in the IPN, my master is in Water resources in the coast, can you send me this M fil and the excel file you use, :) if you can I'll appreciate it, and when I finish mine, I'll send it to you... plus I want to print Hm and Tm :D.
Greetins and thanks (alejandropaladio@gmail.com) :D