Matlab Code with Numbered Steps
1. fs = 800; // sampling frequency
2. t = [0:1/fs:4-(1/fs)]; // time interval from 0 to 4 seconds
3. l = length(t); // Length of the time vector
4. f = [-l/2:1:l/2-1] .* fs/l; // Creating frequency indices
5. Vm1 = 3; // New amplitude of modulating signal 1
6. Vm2 = 3.5; // New amplitude of modulating signal 2
7. fm1 = 40; // New frequency of modulating signal 1
8. fm2 = 60; // New frequency of modulating signal 2
9. v_m1 = Vm1 .* sin(2 .* %pi .* fm1 .* t); // Expression for modulating signal 1
10. v_m2 = Vm2 .* sin(2 .* %pi .* fm2 .* t); // Expression for modulating signal 2
11. fdm = v_m1 + v_m2; // Addition (fdm) of modulating signals
12. figure(1)
13. subplot(3,1,1)
14. plot(t, v_m1)
15. xlabel("Time")
16. ylabel("Amplitude")
17. title("Modulating Signal 1")
18. subplot(3,1,2)
19. plot(t, v_m2)
20. xlabel("Time")
21. ylabel("Amplitude")
22. title("Modulating Signal 2")
23. s1 = abs(fftshift(fft(v_m1))); // Taking FFT of signal 1
24. s2 = abs(fftshift(fft(v_m2))); // Taking FFT of signal 2
25. FDM = abs(fftshift(fft(fdm))); // Taking FFT of combined signal
26. figure(2)
27. subplot(3,1,1)
28. plot(f, s1)
29. xlabel("Frequency")
30. ylabel("Amplitude")
31. title("Spectrum of Signal 1")
32. subplot(3,1,2)
33. plot(f, s2)
34. xlabel("Frequency")
35. ylabel("Amplitude")
36. title("Spectrum of Signal 2")
37. subplot(3,1,3)
38. plot(f, FDM)
39. xlabel("Frequency")
40. ylabel("Amplitude")
41. title("Added Spectrum")
42. BPF1 = (abs(f) > fm1-15) & (abs(f) < fm1+15); // Bandpass filter design 1
43. BPF2 = (abs(f) > fm2-25) & (abs(f) < fm2+25); // Bandpass filter design 2
44. S1_extracted = FDM .* BPF1; // Filtering signal 1
45. S2_extracted = FDM .* BPF2; // Filtering signal 2
46. A = ifft(ifftshift(S1_extracted)); // Inverse FFT to recover signal 1
47. B = ifft(ifftshift(S2_extracted)); // Inverse FFT to recover signal 2
48. figure(3)
49. subplot(3,1,1)
50. plot(t, A)
51. xlabel("Time")
52. ylabel("Amplitude")
53. title('Recovered Signal 1')
54. subplot(3,1,2)
55. plot(t, B)
56. xlabel("Time")
57. ylabel("Amplitude")
58. title('Recovered Signal 2')