Latex 使用mcode 插入matlab程式碼
阿新 • • 發佈:2019-01-29
首先安裝mcode巨集包
在latex中使用mcode插入matlab程式碼
\documentclass{report}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx,subfig}
\usepackage{caption}
\usepackage[numbers]{natbib}
\usepackage{listings}
\lstset{language=Matlab}
\usepackage[framed,numbered,autolinebreaks,useliterate]{mcode} %%使用巨集包mcode
\begin{document}
\maketitle
\begin{lstlisting} %%其中為matlab程式碼
%%%100points
clear all;clc;
Fs = 10; % Sampling frequency
T = 1/Fs; % Sample time
L = 100; % Length of signal 100
t = (0 :L-1)*T; % Time vector
% Generate the signal
x=2.6*sin(4.2*pi*t+unifrnd(0,4*pi));
y=2.1*sin(4.4*pi*t+unifrnd(-pi,pi));
\end{lstlisting}
\end{document}