How to insert noise in a signal using matlab?
조회 수: 10 (최근 30일)
이전 댓글 표시
Hi. I want to create a signal with noise. I found this coding but I don't know how it works. Can somebody explain this to me?
x= cos(2*pi*12*[0:0.001:1.23]);
x(end) = [];
[b a] = butter(2,[0.6 0.7],'bandpass');
filtered_noise = filter(b,a,randn(1, length(x)*2));
x = (x + 0.5*filtered_noise(500:500+length(x)-1))/length(x)*2;
This is the result when I plot the x.
댓글 수: 0
채택된 답변
Star Strider
2015년 11월 5일
It creates a signal in ‘x’, then creates band-limited noise by bandpass-filtering a Gaussian random vector (created by the randn call), the same length as ‘x’, and stores it in the ‘filtered_noise’ variable. It then adds that to the original ‘x’ and scales it to create the final value of ‘x’. (There is a bit more involved in the code than I described, but that is the essence of it.)
댓글 수: 6
Star Strider
2015년 11월 5일
That appears to be correct.
If you want the frequency in Hz (again assuming the time unit is seconds), multiply the normalised frequency by Fn, or 500 Hz.
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!