Skip to content

Instantly share code, notes, and snippets.

@matiskay
Last active November 17, 2015 22:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matiskay/fc6d1367fb3a47bc8664 to your computer and use it in GitHub Desktop.
Save matiskay/fc6d1367fb3a47bc8664 to your computer and use it in GitHub Desktop.
\documentclass[a4paper,12pt]{article}
\usepackage{upquote}
\usepackage{listings}
% Check
\definecolor{ao(english)}{rgb}{0.0, 0.5, 0.0}
\definecolor{ao}{rgb}{0.0, 0.0, 1.0}
\definecolor{alizarin}{rgb}{0.82, 0.1, 0.26}
\definecolor{byzantium}{rgb}{0.44, 0.16, 0.39}
\definecolor{burntorange}{rgb}{0.8, 0.33, 0.0}
\usepackage{inconsolata}
\renewcommand{\lstlistingname}{Algorithm}
% Based on https://gist.github.com/eyliu/120689
\lstset{language=Matlab,
frame=single,
showspaces=false,
showtabs=false,
breaklines=true,
showstringspaces=false,
breakatwhitespace=true,
escapeinside={(*@}{@*)},
morekeywords={plot, title, xlabel},
morekeywords=[2]{alpha, beta, theta, kappa, gamma},
deletekeywords={alpha, beta, gamma},
commentstyle=\usefont{T1}{pcr}{m}{sl}\color{ao(english)}\small,
numbers=left,
keywordstyle=\color{ao} \bfseries,
keywordstyle=[2]\color{burntorange} \bfseries,
stringstyle=\color{alizarin},
basicstyle=\ttfamily\small,
numberstyle=\ttfamily,
}
\begin{document}
\lstinputlisting[caption={Modelo SEIRS},label=lst:seir_model,firstline=14]{seirs.m}
\end{document}
% SEIRS model
% Inputs:
% t - time variable: not used here because our system
% is independent of the time (autonomous)
% x - independent variable: this contains the populations.
% Output:
% dx - First derivative: The rate of change of the population.
% S = dx_dt(1)
% E = dx_dt(2)
% I = dx_dt(3)
% R = dx_dt(4)
function dx_dt = seirs_model(t, x)
dx_dt = [0; 0; 0; 0];
alpha = 0.375;
beta = 0.1;
gamma = 0.143;
theta = 0.004;
kappa = 0.00042;
dx_dt(1) = - alpha * x(1) + theta * x(4);
dx_dt(2) = alpha * x(1) - beta * x(2);
dx_dt(3) = beta * x(2) - kappa * x(3) - gamma * x(3);
dx_dt(4) = gamma * x(3) - theta * x(4);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment