generated from Tarang74/QUT-Notes-Template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
657 additions
and
54 deletions.
There are no files selected for viewing
File renamed without changes.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
Fs = 8000; % Sampling rate | ||
T = 0.2; % Duration | ||
|
||
Fm = 10; % Message signal frequency | ||
Ac = 1; % Carrier amplitude | ||
Fc = 300; % Carrier frequency | ||
|
||
samples = Fs * T; | ||
|
||
% Time vector | ||
t = linspace(0, T, samples + 1); t(end) = []; | ||
% Frequency vector | ||
f = linspace(-Fs / 2, Fs / 2, samples + 1); f(end) = []; | ||
|
||
x = cos(2 * pi * Fm * t); % Message signal | ||
c = Ac * cos(2 * pi * Fc * t); % Carrier waveform | ||
|
||
%% DSB-SC modulation | ||
y1 = x .* c; | ||
|
||
figure(), title('DSB-SC'), subplot(2, 1, 1) | ||
plot(t, x, 'm', 'LineWidth', 1), hold on | ||
plot(t, c, 'c--'), plot(t, y1, 'k--') | ||
xlabel('Time (sec)'), ylabel('Amplitude') | ||
legend('m(t)', 'c(t)', 's(t)') | ||
|
||
% Spectral Characteristics of the DSB-SC signal | ||
X = fft(x); C = fft(c); Y = fft(y1); | ||
|
||
subplot(2, 1, 2) | ||
stem(f, abs(fftshift(X)) / Fs, '.m', 'LineWidth', 1), hold on | ||
stem(f, abs(fftshift(C)) / Fs, '.c') | ||
stem(f, abs(fftshift(Y)) / Fs, '.k') | ||
xlabel('Frequency (Hz)'), ylabel('Magnitude') | ||
legend('M(f)', 'C(f)', 'Y(f)'), axis([-2 * Fc 2 * Fc 0 0.15]) | ||
|
||
%% DSB-FC modulation | ||
mu = 2; % Modulating index | ||
y2 = (1 + mu * x) .* c; | ||
|
||
figure(), title('DSB-FC'), subplot(2, 1, 1) | ||
plot(t, x, 'm', 'LineWidth', 1), hold on | ||
plot(t, c, 'c--'), plot(t, y2, 'k--') | ||
xlabel('Time (sec)'), ylabel('Amplitude') | ||
legend('m(t)', 'c(t)', 'y(t)') | ||
|
||
% Task - Change the modulation index, and observe the resultant modulated signal. | ||
% Comment on the results | ||
|
||
% Spectral Characteristics of the DSB-FC signal | ||
Y = fft(y2); | ||
|
||
subplot(2, 1, 2) | ||
stem(f, abs(fftshift(X)) / Fs, '.m', 'LineWidth', 1), hold on | ||
stem(f, abs(fftshift(C)) / Fs, '.c') | ||
stem(f, abs(fftshift(Y)) / Fs, '.k') | ||
xlabel('Frequency (Hz)'), ylabel('Magnitude') | ||
legend('M(f)', 'C(f)', 'Y(f)'), axis([-2 * Fc 2 * Fc 0 0.15]) | ||
|
||
%% Recovering the original signal | ||
x_baseband = y2; | ||
x_baseband(x_baseband < 0) = 0; % Rectified Signal | ||
|
||
X_filt = fft(x_baseband); % Spectral components | ||
X_filt(abs(ifftshift(f)) > 2 * Fm) = 0; % Filtering to remove high frequency carrier | ||
|
||
x_demod = real(ifft(X_filt)); % Recover the signal | ||
x_demod = x_demod - mean(x_demod); % Remove the DC bias | ||
|
||
% Plot against original | ||
figure() | ||
hold on | ||
plot(t, x, 'k') | ||
plot(t, x_demod, 'r--') | ||
xlabel('Time [s]'), ylabel('Amplitude') | ||
legend('x(t)', 'x_{rx}(t)') |
This file was deleted.
Oops, something went wrong.
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
@ECHO OFF | ||
|
||
setlocal ENABLEDELAYEDEXPANSION | ||
|
||
@REM Display help text | ||
IF "%~1"=="-h" GOTO :help | ||
IF "%~1"=="-help" GOTO :help | ||
|
||
@REM Set global variables | ||
@REM Script name | ||
SET scriptname=%~nx0 | ||
|
||
@REM Script mode | ||
SET /A file=0 | ||
SET /A recursive=0 | ||
|
||
@REM Options | ||
SET /A verbose=0 | ||
SET /A open=0 | ||
|
||
SET /A tex="a" | ||
|
||
@REM Set mode | ||
IF "%1"=="" GOTO :noMode | ||
|
||
IF "%1"=="recursive" ( | ||
SET recursive=1 | ||
) ELSE ( | ||
IF "%1"=="file" ( | ||
SET file=1 | ||
) ELSE ( | ||
GOTO :invalidMode | ||
) | ||
) | ||
|
||
SHIFT | ||
SET directory=%~1 | ||
SHIFT | ||
|
||
IF %file%==1 ( | ||
SET tex=%~1 | ||
SHIFT | ||
) | ||
|
||
@REM If no parameters, build without opening | ||
IF "%1"=="" GOTO :default | ||
|
||
@REM Loop through all parameters | ||
SET /A numP=0 | ||
|
||
:loop | ||
@REM Use numP to test each parameter for validity | ||
SET numP=0 | ||
|
||
@REM Check options | ||
IF "%1"=="-v" ( | ||
SET numP=1 | ||
SET verbose=1 | ||
) ELSE ( | ||
IF "%1"=="-verbose" ( | ||
SET numP=1 | ||
SET verbose=1 | ||
) | ||
) | ||
IF "%1"=="-o" ( | ||
SET numP=1 | ||
SET open=1 | ||
) ELSE ( | ||
IF "%1"=="-open" ( | ||
SET numP=1 | ||
SET open=1 | ||
) | ||
) | ||
|
||
@REM If current option is not valid | ||
IF !numP!==0 GOTO :invalidOption | ||
|
||
@REM Shift variables and loop if another option exists | ||
SHIFT | ||
IF NOT "%1"=="" GOTO :loop | ||
|
||
:: Default | ||
:default | ||
IF NOT EXIST "%directory%" GOTO :invalidDirectory | ||
|
||
IF %recursive%==1 ( | ||
FOR /R "%directory%" %%i IN (*.TIKZ) DO ( | ||
SET tex=%%~ni | ||
CALL :main | ||
) | ||
) ELSE ( | ||
CALL :main | ||
) | ||
|
||
@REM Finally: | ||
GOTO :EOF | ||
|
||
:: Main function | ||
:main | ||
@REM Verbose options | ||
IF %verbose%==0 ( | ||
CALL :buildPDF | ||
) ELSE ( | ||
CALL :buildPDFv | ||
) | ||
|
||
@REM Open options | ||
IF %open%==1 ( | ||
CALL :openPDF | ||
) | ||
|
||
EXIT /B | ||
|
||
:: Build PDF | ||
:buildPDF | ||
ECHO -- Building PDF -- | ||
latexmk -aux-directory=Debug -shell-escape -file-line-error -interaction=nonstopmode -halt-on-error -output-directory=figures -silent -xelatex %directory%/%tex%.tikz | ||
EXIT /B | ||
|
||
:: Build PDF verbose | ||
:buildPDFv | ||
ECHO -- Building PDF -- (v) | ||
latexmk -aux-directory=Debug -shell-escape -file-line-error -interaction=nonstopmode -halt-on-error -output-directory=figures -verbose -xelatex %directory%/%tex%.tikz | ||
EXIT /B | ||
|
||
:: Open PDF | ||
:openPDF | ||
ECHO -- Opening PDF -- | ||
figures\%tex%.pdf | ||
EXIT /B | ||
|
||
:: Help | ||
:help | ||
ECHO %scriptname% compile tikz diagrams using XeLaTeX. | ||
ECHO. | ||
ECHO Usage: %scriptname% file [directory] [filename] [options] | ||
ECHO %scriptname% recursive [directory] [options] | ||
ECHO. | ||
ECHO Available options: | ||
ECHO %scriptname% [-h ^| -help] Provides help information. | ||
ECHO %scriptname% [filename] [-v ^| -verbose] Show compiler output. | ||
ECHO %scriptname% [filename] [-o ^| -open] Open the PDF after compilation. | ||
GOTO :EOF | ||
|
||
:: No Mode | ||
:noMode | ||
ECHO No mode provided. [file ^| recursive] expected. | ||
ECHO Try "%scriptname% -h" for more information. | ||
GOTO :EOF | ||
|
||
:: Invalid Option | ||
:invalidOption | ||
ECHO Unknown option: %1 | ||
ECHO Try "%scriptname% -h" for more information. | ||
GOTO :EOF | ||
|
||
:: Invalid Mode | ||
:invalidMode | ||
ECHO Invalid mode provided. [file ^| recursive] expected. | ||
ECHO Try "%scriptname% -h" for more information. | ||
GOTO :EOF | ||
|
||
:: No Directory | ||
:noDirectory | ||
ECHO No directory was supplied. | ||
ECHO Try "%scriptname% -h" for more information. | ||
GOTO :EOF | ||
|
||
:: Invalid Directory | ||
:invalidDirectory | ||
ECHO Directory "%directory%" is invalid. | ||
ECHO Try "%scriptname% -h" for more information. | ||
GOTO :EOF |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
%!TEX TS-program = xelatex | ||
%!TEX options = -aux-directory=Debug -shell-escape -file-line-error -interaction=nonstopmode -halt-on-error -synctex=1 "%DOC%" | ||
\documentclass{standalone} | ||
|
||
\usepackage{unicode-math} | ||
\setmathfont{Latin Modern Math} | ||
\setmathfont{TeX Gyre Pagella Math}[range={bb,bbit}, Scale=MatchUppercase] | ||
|
||
\usepackage[dvipsnames]{xcolor} | ||
\usepackage{tikz} | ||
\usetikzlibrary{positioning,decorations.pathreplacing,calligraphy} | ||
|
||
\begin{document} | ||
\begin{tikzpicture} | ||
\node [ | ||
draw, | ||
fill=SeaGreen, | ||
text width=2cm, | ||
inner sep=0.3cm, | ||
align=center, | ||
minimum height=1.2cm | ||
] (sp1) {Signal\\ Processing}; | ||
\node [ | ||
draw, | ||
fill=SeaGreen, | ||
text width=2cm, | ||
minimum height=1.2cm, | ||
inner sep=0.3cm, | ||
align=center, | ||
right=1cm of sp1 | ||
] (cc1) {Carrier\\ Circuit}; | ||
\node [ | ||
draw, | ||
fill=OrangeRed, | ||
text width=2.5cm, | ||
minimum height=1.2cm, | ||
inner sep=0.3cm, | ||
align=center, | ||
right=2cm of cc1 | ||
] (tm) {Transmission\\ Medium\\ (Channel)}; | ||
\node [ | ||
draw, | ||
fill=SkyBlue, | ||
text width=2cm, | ||
minimum height=1.2cm, | ||
inner sep=0.3cm, | ||
align=center, | ||
right=2cm of tm | ||
] (cc2) {Carrier\\ Circuit}; | ||
\node [ | ||
draw, | ||
fill=SkyBlue, | ||
text width=2cm, | ||
minimum height=1.2cm, | ||
inner sep=0.3cm, | ||
align=center, | ||
right=1cm of cc2 | ||
] (sp2) {Signal\\ Processing}; | ||
% | ||
\draw[<-] (sp1.west) -- ++ (-3, 0) node[at end, anchor=west, below right, label={[at end, above right, align=left]Information\\ Input}] {\(m\left( t \right)\)}; | ||
\draw[->] (sp1.east) -- (cc1.west); | ||
% | ||
\draw[->] (cc1.east) -- (tm.west) node[midway, below] {\(s\left( t \right)\)}; | ||
\draw[<-] (tm.north) -- ++ (0, 1.5) node[at end, anchor=south, above, text width=1cm, align=center] {Noise\\\(n\left( t \right)\)}; | ||
\draw[->] (tm.east) -- (cc2.west) node[midway, below] {\(r\left( t \right)\)}; | ||
% | ||
\draw[->] (cc2.east) -- (sp2.west); | ||
\draw[->] (sp2.east) -- ++ (3, 0) node[at end, anchor=east, below left, label={[at end, above left, align=right]Information\\ Output}] {\(\hat{m}\left( t \right)\)}; | ||
% | ||
\draw[decorate,decoration={calligraphic brace,mirror,amplitude=0.3cm,raise=0.2cm},line width=0.03cm] (sp1.south west) -- (cc1.south east) node[midway, below=0.5cm] {Transmitter}; | ||
\draw[decorate,decoration={calligraphic brace,mirror,amplitude=0.3cm,raise=0.2cm},line width=0.03cm] (cc2.south west) -- (sp2.south east) node[midway, below=0.5cm] {Receiver}; | ||
\end{tikzpicture} | ||
\end{document} |