Thursday, February 22, 2018

Restorasi Sinyal Berderau Berbasis Tapis Chebyshev




Antarmuka GUI MATLAB ini dapat dipakai untuk laboratorium sinyal bagi mahasiswa dan untuk menunjang penelitian bagi para peneliti. Anda bisa memesannya pada form pemesanan di bawah ini.

















KODE UNTUK SALAH SATU EVENT CALLBACK:


  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
function tombolCheby1_Callback(hObject, eventdata, handles)
% hObject    handle to tombolCheby1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

if (handles.fileDimuat==1)
    N = 300;
    OK = 0;

    switch (handles.TapisTerseleksi2)
        case (1)
            % Lowpass:
            Fpass  = str2num(get(handles.editF3,'String'));
            if (length(Fpass)>0)
                if (Fpass<handles.Fs/2-30)
                    handles.Fpass = Fpass;
                    [b,a] = cheby1(6,10,Fpass/(handles.Fs/2),'low');
                    [h,w] = freqz(b,a);
                    %Hd = BangkitkanTapisLowpass(Fpass, Fstop, handles.Fs, N);
                    OK = 1;
                else
                    msgbox('Nila frek tidak ada pada rentang tepat','Nilai Frek Salah','error');
                end
            else
                msgbox('Nilai-Nilai Frek Tidak Ada! Silahkan isi dan coba kembali.','Nilai Frek Tidak Ada','error');
            end
        case (2)      
            % Highpass:
            Fpass = str2num(get(handles.editF3,'String'));            
            if (length(Fpass)>0)
                if (Fpass<handles.Fs/2-30)                
                    handles.Fpass = Fpass;
                    [b,a] = cheby1(6,10,Fpass/(handles.Fs/2),'high');
                    [h,w] = freqz(b,a);
                    OK = 1;
                else
                    msgbox('Nila frek tidak ada pada rentang tepat','Nilai Frek Salah','error');
                end
            else
                msgbox('Nilai-Nilai Frek Tidak Ada! Silahkan isi dan coba kembali.','Nilai Frek Tidak Ada','error');
            end
        case (3)
            % Bandpass:
            Fpass1 = str2num(get(handles.editF3,'String'));            
            Fpass2 = str2num(get(handles.editF4,'String'));
            if ((length(Fpass1)>0) & (length(Fpass2)>0))            
                   handles.Fpass1 = Fpass1;
                   handles.Fpass2 = Fpass2;
                   %Fpass1
                   [b,a] = cheby1(6,10,[Fpass1/(handles.Fs/2) Fpass2/(handles.Fs/2)]);
                   [h,w] = freqz(b,a);
                   OK = 1;
            else
                msgbox('Nilai-Nilai Frek Tidak Ada! Silahkan isi dan coba kembali.','Nilai Frek Tidak Ada','error');
            end
            
        case (4)
            % Bandstop:
            Fpass1 = str2num(get(handles.editF3,'String'));            
            Fpass2 = str2num(get(handles.editF4,'String'));
            if ((length(Fpass1)>0) & (length(Fpass2)>0))            
                   handles.Fpass1 = Fpass1;
                   handles.Fpass2 = Fpass2;
                   %Fpass1
                   [b,a] = cheby1(6,10,[Fpass1/(handles.Fs/2) Fpass2/(handles.Fs/2)],'stop');
                   [h,w] = freqz(b,a);
                   OK = 1;

            else
                msgbox('Nilai-Nilai Frek Tidak Ada! Silahkan isi dan coba kembali.','Nilai Frek Tidak Ada','error');
            end
    end
    
    if (OK==1)
        axes(handles.sumbuTapis);
        %[h,w] = freqz(b,a);
        [H,F] = freqz(b,a,N,handles.Fs);
        plot(F,20*log10(abs(H)))
        title('Tapis Yang Dirancang');

     
        xFinal = filter(b,a,handles.x2);
        handles.xFinal = xFinal;

        axes(handles.sumbuSpektrumAkhir);
        specgram(handles.xFinal, 1024, handles.Fs);
        title('Spektrum Sinyal Penapisan');
        
        % Menghitung MSE dan PSNR
        [M,N]=size(handles.xFinal);
        err = sum((handles.x-handles.xFinal).^2)/(M*M);
        MSE=sqrt(err);
        NILMAKS=65535;
        PSNR = 20*log10(NILMAKS/MSE);

        set(handles.edit6, 'String', num2str(MSE));
        psnr = [num2str(PSNR) ' dB']; 
        set(handles.edit7, 'String', psnr);
        
        %Persentase efisiensi
        EFF = ((handles.mse1 - MSE)/ handles.mse1)* 100;
        eff = [num2str(EFF) ' %']; 
        set(handles.edit22, 'String', eff);
        
        handles.fileFinal=1;
    end
           
    
end
guidata(hObject, handles);


No comments: