• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Apr 3rd, 2019 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1.
2. % simulate1fnoise(number of samples,
3. %                 signal amplitude ,
4. %                 signal frequency ,
5. %                 number of redundant sensors to simulate (each has independent noise),
6. %                 starting probability of each update)
7. % Outputs:
8. %
9. % pure_signal = physical signal we want to measure
10. % ideal_measurement = the best we could expect, after denoising (additive
11. %                                                       noise limited)
13. % acquisition_signal = Simulated measurement. What we would actually
14. % obtain.
15. % update_noise       = the step-like noise which we want to remove, due to
17. % refUpdates         = time instants at which the reference is updated, and we
18. %                      have step-function noise
19.
20. % The information we have available in the real case is refUpdates and
21. % acquisition_signal.
22.
23.
24. nsamp = 1000; t = 1:nsamp; nSensors = 10;
26.
27.
28. figure, subplot(1,2,1), plot(t,ideal_measurement(1,:),t,pure_signal(1,:),'r'),
29.         title('Ideal case for measurement (no updates)'), legend({'Ideal Measurement', 'Pure Signal'})
30.         xlabel('time')
31.         subplot(1,2,2), plot(t,acquisition_signal(1,:),t,update_noise(1,:),'r'),
32.         title('Actual measurement'), legend({'Acquisition', 'Step noise'})
33.         xlabel('time')
34.
35.
37.
38.
39. t = 1:nsamp;
40. pure_signal = amp*sin(2*pi*freq*t).*[zeros(1,floor(nsamp/4)) hamming(floor(nsamp/2))' zeros(1,nsamp-(floor(nsamp/2) + floor(nsamp/4)))] ;
41.
43. ideal_measurement = pure_signal + additive_noise; % What one would ideally measure
44. update_noise = zeros(nWindows,nsamp);   % Noise resulting from updates (the part that we want to discover/remove from our signal)
45. acquisition_signal = zeros(nWindows,nsamp);    % Actual physical measurement
46.
48.
49. for wnd = 1:nWindows
50.     updateError = 0;
52.     for idx = 1:nsamp
54.         acquisition_signal(wnd,idx) = ideal_measurement(wnd,idx) + updateError;
55.         update_noise(wnd,idx) = updateError;