Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clear
- close all
- %Initial Data
- A = 8e-3;
- F0 = 3000;
- Fs = 48000;
- Q = 3;
- N = 10;
- m = 0;
- sq = A;
- D = 1/Q*100;
- t = 0:1/Fs:N*1/F0-1/Fs;
- t0 = -(1/F0-1/Fs):1/Fs:1/F0-1/Fs;
- %Single Rectangular Signal
- y0 = A*rectpuls(t0, 1/F0*(D/100));
- subplot(3, 3, 1)
- plot(t0, y0)
- title('Original Single Signal')
- %Periodic Rectangular Signal
- y1 = A*(square(2*pi*F0*t, D));
- subplot(3, 3, 2);
- plot(t, y1);
- title('Origianl Periodic Signal');
- %White Noise
- y2 = sq*(rand(1, length(y1))-0.5);
- subplot(3, 3, 3)
- plot(t, y2)
- title('White Noise')
- %Signal-noise Mixture
- y3 = y1 + y2;
- subplot(3, 3, 4)
- plot(t, y3)
- title('Signal-noise mixture')
- %ACF of Single Rectangular Signal
- [ACF_y0, lags0] = xcorr(y0);
- subplot(3, 3, 5)
- plot(lags0, ACF_y0)
- title('Single Signal ACF')
- %ACF of Periodic Rectangular Signal
- [ACF_y1, lags1] = xcorr(y1);
- subplot(3, 3, 6)
- plot(lags1, ACF_y1)
- title('Pediodic Signal ACF')
- %Interval from Mixture
- start_T = randi(N/2, 1, 1);
- end_T = start_T+randi(N/2, 1, 1);
- period = floor(length(y3)/N);
- y3_interval = y3(period*start_T:period*end_T);
- subplot(3, 3, 7);
- plot(t(period*start_T:period*end_T),y3_interval);
- title('Interval from mixture');
- [CCF_y3Xy3_interval, lags2] = xcorr(y3, y3_interval);
- subplot(3, 3, 8)
- plot(lags2,CCF_y3Xy3_interval)
- title('Cross Correlation for Y3 and interval')
- CCF_max = max(CCF_y3Xy3_interval);
- disp(CCF_max)
- CCF_max_index = find(CCF_y3Xy3_interval==CCF_max);
- disp(CCF_max_index)
- %Find original interval
- left_border_index = round(CCF_max_index - length(y3_interval)/2);%?
- right_border_index = round(CCF_max_index + length(y3_interval)/2);%?
- display(left_border_index)
- display(right_border_index)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement