Last active
April 5, 2020 12:57
-
-
Save brilliant-ember/71129da5599e23dbdc39bb315016cd64 to your computer and use it in GitHub Desktop.
Plot periodic functions in Octave or Matlab with this script. It multiplies (modulates) the carrier and the msg signals, and plots the time domain and FFT reprisentation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% referenced gist https://gist.github.com/akiatoji/5649907 | |
clear ; close all; clc | |
fundPeriod = pi/1000; | |
num_tsteps = 1000; | |
num_periods = 4; | |
tstep = num_periods * fundPeriod / num_tsteps; | |
t = 0:tstep:(num_periods * fundPeriod); | |
msg = 2*cos(400*t)+4*sin(500*t+pi/3); | |
carrier = cos(8000*pi*t); | |
modulatedMsg = msg.*carrier; | |
f_s = num_tsteps / (fundPeriod*num_periods); | |
n = 2**16; | |
f = f_s*(-n/2:n/2-1)/n; | |
subplot(2,2,3); | |
plot(t, msg); | |
title("message Time dom"); | |
grid on; | |
subplot(2,2,4); | |
plot(t, carrier); | |
title("carrier Time dom"); | |
grid on; | |
subplot(2,2,1); | |
plot(t,modulatedMsg); | |
title("modulated time domain"); | |
grid on; | |
y = abs(fft(modulatedMsg,n)); | |
y = fftshift(y); | |
subplot(2,2,2); | |
stem(f, y); | |
title("fast fourier"); | |
grid on; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Multiplying msg = 2cos(400t)+4sin(500t+pi/3); with carrier = cos(8000pit); will give us an AM modulated signal, and we see that it is a DSB-SC, as we have a double side band, and the amplitude at Fcarrier ( centre freq in the fft graph if you plotted it) is zero means that it is suppressed carrier, hence the SC.