Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- close all; clear; clc;
- Fs = 50;
- t = 0:(1/Fs):10;
- harm1 = sin(2*pi*2.*t);
- harm2 = 0.5*sin(2*pi*5.*t);
- gauss = 0.5*0.5*exp((-(t-0.5).^2)/(2*0.5*0.5));
- x = harm1 + harm2 + gauss;
- x_szum = x + 0.2*randn(size(t));
- oc =@(x,y) sqrt(((x-y)*(x-y)'));
- k = 1;
- for n=3:2:71
- %srednia
- x_avg = conv(x_szum, ones(1, n)/n, 'same');
- wa(k) = oc(x, x_avg);
- %gauss
- n2 = floor(n/2);
- odch = n/6;
- temp1 = exp((-(-n2:n2).^2)/(2*odch*odch));
- temp1 = temp1/sum(temp1);
- x_gauss = conv(x_szum, temp1, 'same');
- wa_gauss(k) = oc(x, x_gauss);
- temp2 = medfilt1(x, n);
- wa_mediana(k)= oc(x, temp2);
- temp3 = wiener2(x_szum, [1 n]);
- wa_wiener(k) = oc(x, temp3);
- k = k+1;
- end
- tt = 3:2:71;
- %plot(tt, wa, 'r', tt, wa_gauss, 'g', tt, wa_mediana, 'b', ...
- % tt, wa_wiener, 'y');
- gauss = exp((-(-0.03:(1/Fs):0.03).^2)/(2*(3/6).^2));
- gauss = gauss/sum(gauss);
- x_new = conv(x_szum, gauss, 'same');
- %x_new = conv(x_new, ones(1,3)/3, 'same');
- subplot(211), plot(tt, wa, 'r', tt, wa_gauss, 'g',...
- tt, wa_mediana,...
- 'b', ...
- tt, wa_wiener, 'y');
- subplot(212), plot(t, x, 'r', t, x_new, 'g');
- oc(x, x_new)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement