% ( [ {
\documentclass[12pt,mathserif]{article}

%\usepackage{behavior-modi,add_behavior}
%\usepackage[pdftex]{graphicx}
\usepackage{hyperref}
\usepackage{graphicx}
\usepackage{graphics,floatflt}
\usepackage{mathrsfs}
\usepackage{amsmath,amssymb}
\usepackage{textcomp}
\usepackage{wasysym}
%\usepackage{amssymb}
% \usepackage{mathtime}
\usepackage{mathptmx}
\usepackage{helvet}

\graphicspath{{figures/}}

\addtolength{\textwidth}{35mm}
\addtolength{\textheight}{45mm}
\addtolength{\topmargin}{-25mm}
\addtolength{\oddsidemargin}{-25mm}
\addtolength{\evensidemargin}{-25mm}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\bullettop}[1]{\overset{\bullet}{#1}}
\newcommand{\Chi} {\mbox{\put(0,3){\large $\chi$}\hspace*{2.4mm}}}
\renewcommand{\det}{\mathrm{det~}}
\newcommand{\degdet}[1]{\deg(\det(#1))}
\renewcommand{\ker}{\mathrm{ker~}}
\newcommand{\im}{\mathrm{im~}}
\newcommand{\w}{\texttt{w}}

\newcommand{\blue}[1]{{{#1}}}
\newcommand{\black}[1]{{\color{black}{#1}}}

\newcommand{\enl}{\displaystyle }

\newtheorem{theo}{Theorem}
\newtheorem{fact}[theo]{Fact}
\newtheorem{defn}[theo]{Definition}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\F}{\mathbb{F}}
\newcommand{\V}{\mathbb{V}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\C}{\mathbb{C}}
\newcommand{\ddt}{\frac{\mathrm{d}}{\mathrm{d}t}}
\newcommand{\dt}{\mathrm{d}t}
\newcommand{\dm}{\mathrm{d}}
\renewcommand{\ker}{\mathrm{ker~}}
\newcommand{\rank}{\mathrm{rank~}}
\renewcommand{\im}{\mathrm{im~}}
\newcommand{\Rw}{\R^{\w\times\w}}
\newcommand{\Rn}{\R^{n}}
\newcommand{\Rm}{\R^{m}}
\newcommand{\Cn}{\C^{n}}
\newcommand{\Rmm}{\R^{m\times m}}
\newcommand{\Rnn}{\R^{n\times n}}
\newcommand{\Rmn}{\R^{m\times n}}
\newcommand{\Rnm}{\R^{n\times m}}
\newcommand{\RNN}{\R^{N\times N}}
\newcommand{\Rkk}{\R^{k\times k}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\parindent 0mm

\newcommand{\synt}[1]{\hspace*{2mm}{\tt{#1}\\}}

\begin{document}

\centerline{\Large \bf EE302: Root locus, Nyquist plot, Bode plots, Matlab/Octave/Scilab}

Please write about corrections/typos to belur@iitb.ac.in. Document date: 26th March 2020\\

This note has information about Matlab, Octave and Scilab for use in control.
Some comparison and some basic commands (for root locus, etc) is also included
in this note.

All three: Matlab, Octave and Scilab are \underline{numerical} computational
packages with many advanced features/capabilities too. Several basic/complicated
plots are possible in all three. Accuracy and speed are \underline{exactly same} for all important
numerical computation (like eigenvalues, roots of polynomials, control theory
computation). 

Vector, matrix, array, for-loop, while-loop, syntax is exactly the same.

Our recommendation: choose any one of: Octave/Matlab (pair) or Scilab: and don't
keep debating and wasting valuable time. 

All three packages are available in Windows, Linux (and most likely in Mac). Read below about
pros/cons and then the syntax for Octave and Scilab for root-locus, Bode plot, Nyquist plot.\\

{\bf Matlab}\\
\underline{Pros:} Excellent proprietary package: has many toolboxes. 
Including Simulink. Simulink is pretty
unmatched. Nearest FOSS alternatives are not as good (as far as advanced users' opinion goes).\\
\underline{Cons:} Price: exorbitant. Matlab skills make us very very dependent on our company/institution
 renewing this expensive package/toolboxes. Increasingly, FOSS packages are making instututes
debate abour renewing Matlab (and thus making your Matlab capabilities redundant
and hence you vulnerable).
Do not use pirated version. Institute gets into trouble by these bad 
habits/mal-practices (and hence Institute would not bail out 
a defaulter in this matter. Each one of you has signed the IT-policy 
of the institute and hence you are subject to stringent laws 
about pirated package usage. Please do not take chances with pirated packages.) 

See later below about how it is very easy to manage
with Octave/Scilab for
the requirements in this course (and of course for advanced things too).\\


{\bf Octave}\\
\underline{Pros:} For all basic (and not so advanced) things: Octave works exactly like Matlab
on the code that is written for Matlab. (Octave's strength is that Octave aims to run your
Matlab code and give output like Matlab would.)\\
\underline{Cons:} All toolboxes of Matlab do not yet have Octave versions. 
(Most developers of Octave spend time voluntarily and guaranteeing Matlab's output
needs effort.) Simulink-alternative not yet in Octave.\\

{\bf Scilab}\\
\underline{Pros:} Scilab has many advanced toolboxes (control systems,
signal processing, statistics, image processing, video processing, optimization
and many more). Simulink-equivalent (called Xcos) is reasonably good.\\
\underline{Cons:} Syntax not exactly same like Matlab. (But very similar
for matrix/vector/basic-operations purposes.)

{\bf Control systems specific commands}
There is a lot of help on all basic requirements (including control) on the
Internet and within the package. We are listing only the basic commands.
There are excellent spoken tutorials (on www.spoken-tutorial.org) on Scilab: basic
and advanced.\\

{\bf Octave} (This would work for Matlab too)\\
System with transfer function $G(s)=\frac{s+4}{s^2 -5s + 6}$ (say) is defined by using\\
\synt{  \% Octave/Matlab *comment* follows a \% on that line} 
\synt{  \% Commands/variables are case-sensitive: be careful} 
\synt{  \% Files are called file.m files} 
\synt{pkg load control \% AFTER installing control package in octave}
\synt{n=[1 4] \% numerator polynomial coefficients}
\synt{d=[1 -5 6] \% denominator polynomial coefficients}
\synt{sys=tf(n,d) \% one way of defining a system called sys (using `tf')}
\synt{rlocus(sys) \% plots root locus }
\synt{bode(sys) \% plots Bode plot (though system is unstable: interpret cautiously!!}
\synt{nyquist(sys) \% Nyquist plot}
\synt{\% Considering closing the figure before next plot (else, it `super-imposes'?)}


{\bf Scilab} \\
\synt{ \slash \slash Scilab *comment* follows \slash\slash  on that line}
\synt{ \slash \slash Commands/variables are case-sensitive: be careful} 
\synt{ \slash \slash Files are called file.sci (or file.sce) files} 
\synt{ s=poly(0,'s') \slash \slash Define s as the polynomial in the variable 's' with root 0}
\synt{ s=\%s \slash \slash alternatively, some *built-in* items, like \%pi, \%e (for 2.718), }
\synt{\slash \slash More built-ins: \%i,\%j (for sqrt(-1)),\%eps, etc }
\synt{ n = s+4 \slash \slash There are other ways too of defining polynomial n (see poly)}
\synt{ d = s$\hat{~}$2 -5 * s + 6 \slash \slash denominator}
\synt{ evans(n,d) \slash \slash for rootlocus: named after its inventor: Walter Evans}
\synt{ sys=syslin('c',n,d) \slash \slash continuous time system: 2 arguments means num, den} 
\synt{ evans(sys) \slash \slash evans works with both: num/den (2 arguments) or sys (1 argument)}
\synt{ bode(sys) \slash \slash plots Bode plot (though system is unstable: interpret cautiously!!}
\synt{ nyquist(sys) \slash \slash Nyquist plot} 
% \synt{  \slash \slash }

\end{document}

\end{document}

% ) ] }


