Graduationwoot

Dragon Notes

i

\( \newcommand{bvec}[1]{\overrightarrow{\boldsymbol{#1}}} \newcommand{bnvec}[1]{\overrightarrow{\boldsymbol{\mathrm{#1}}}} \newcommand{uvec}[1]{\widehat{\boldsymbol{#1}}} \newcommand{vec}[1]{\overrightarrow{#1}} \newcommand{\parallelsum}{\mathbin{\|}} \) \( \newcommand{s}[1]{\small{#1}} \newcommand{t}[1]{\text{#1}} \newcommand{tb}[1]{\textbf{#1}} \newcommand{ns}[1]{\normalsize{#1}} \newcommand{ss}[1]{\scriptsize{#1}} \newcommand{vpl}[]{\vphantom{\large{\int^{\int}}}} \newcommand{vplup}[]{\vphantom{A^{A^{A^A}}}} \newcommand{vplLup}[]{\vphantom{A^{A^{A^{A{^A{^A}}}}}}} \newcommand{vpLup}[]{\vphantom{A^{A^{A^{A^{A^{A^{A^A}}}}}}}} \newcommand{up}[]{\vplup} \newcommand{Up}[]{\vplLup} \newcommand{Uup}[]{\vpLup} \newcommand{vpL}[]{\vphantom{\Large{\int^{\int}}}} \newcommand{lrg}[1]{\class{lrg}{#1}} \newcommand{sml}[1]{\class{sml}{#1}} \newcommand{qq}[2]{{#1}_{\t{#2}}} \newcommand{ts}[2]{\t{#1}_{\t{#2}}} \) \( \newcommand{ds}[]{\displaystyle} \newcommand{dsup}[]{\displaystyle\vplup} \newcommand{u}[1]{\underline{#1}} \newcommand{tu}[1]{\underline{\text{#1}}} \newcommand{tbu}[1]{\underline{\bf{\text{#1}}}} \newcommand{bxred}[1]{\class{bxred}{#1}} \newcommand{Bxred}[1]{\class{bxred2}{#1}} \newcommand{lrpar}[1]{\left({#1}\right)} \newcommand{lrbra}[1]{\left[{#1}\right]} \newcommand{lrabs}[1]{\left|{#1}\right|} \newcommand{bnlr}[2]{\bn{#1}\left(\bn{#2}\right)} \newcommand{nblr}[2]{\bn{#1}(\bn{#2})} \newcommand{real}[1]{\Ree\{{#1}\}} \newcommand{Real}[1]{\Ree\left\{{#1}\right\}} \newcommand{abss}[1]{\|{#1}\|} \newcommand{umin}[1]{\underset{{#1}}{\t{min}}} \newcommand{umax}[1]{\underset{{#1}}{\t{max}}} \newcommand{und}[2]{\underset{{#1}}{{#2}}} \) \( \newcommand{bn}[1]{\boldsymbol{\mathrm{#1}}} \newcommand{bns}[2]{\bn{#1}_{\t{#2}}} \newcommand{b}[1]{\boldsymbol{#1}} \newcommand{bb}[1]{[\bn{#1}]} \) \( \newcommand{abs}[1]{\left|{#1}\right|} \newcommand{ra}[]{\rightarrow} \newcommand{Ra}[]{\Rightarrow} \newcommand{Lra}[]{\Leftrightarrow} \newcommand{rai}[]{\rightarrow\infty} \newcommand{ub}[2]{\underbrace{{#1}}_{#2}} \newcommand{ob}[2]{\overbrace{{#1}}^{#2}} \newcommand{lfrac}[2]{\large{\frac{#1}{#2}}\normalsize{}} \newcommand{sfrac}[2]{\small{\frac{#1}{#2}}\normalsize{}} \newcommand{Cos}[1]{\cos{\left({#1}\right)}} \newcommand{Sin}[1]{\sin{\left({#1}\right)}} \newcommand{Frac}[2]{\left({\frac{#1}{#2}}\right)} \newcommand{LFrac}[2]{\large{{\left({\frac{#1}{#2}}\right)}}\normalsize{}} \newcommand{Sinf}[2]{\sin{\left(\frac{#1}{#2}\right)}} \newcommand{Cosf}[2]{\cos{\left(\frac{#1}{#2}\right)}} \newcommand{atan}[1]{\tan^{-1}({#1})} \newcommand{Atan}[1]{\tan^{-1}\left({#1}\right)} \newcommand{intlim}[2]{\int\limits_{#1}^{#2}} \newcommand{lmt}[2]{\lim_{{#1}\rightarrow{#2}}} \newcommand{ilim}[1]{\lim_{{#1}\rightarrow\infty}} \newcommand{zlim}[1]{\lim_{{#1}\rightarrow 0}} \newcommand{Pr}[]{\t{Pr}} \newcommand{prop}[]{\propto} \newcommand{ln}[1]{\t{ln}({#1})} \newcommand{Ln}[1]{\t{ln}\left({#1}\right)} \newcommand{min}[2]{\t{min}({#1},{#2})} \newcommand{Min}[2]{\t{min}\left({#1},{#2}\right)} \newcommand{max}[2]{\t{max}({#1},{#2})} \newcommand{Max}[2]{\t{max}\left({#1},{#2}\right)} \newcommand{pfrac}[2]{\frac{\partial{#1}}{\partial{#2}}} \newcommand{pd}[]{\partial} \newcommand{zisum}[1]{\sum_{{#1}=0}^{\infty}} \newcommand{iisum}[1]{\sum_{{#1}=-\infty}^{\infty}} \newcommand{var}[1]{\t{var}({#1})} \newcommand{exp}[1]{\t{exp}\left({#1}\right)} \newcommand{mtx}[2]{\left[\begin{matrix}{#1}\\{#2}\end{matrix}\right]} \newcommand{nmtx}[2]{\begin{matrix}{#1}\\{#2}\end{matrix}} \newcommand{nmttx}[3]{\begin{matrix}\begin{align} {#1}& \\ {#2}& \\ {#3}& \\ \end{align}\end{matrix}} \newcommand{amttx}[3]{\begin{matrix} {#1} \\ {#2} \\ {#3} \\ \end{matrix}} \newcommand{nmtttx}[4]{\begin{matrix}{#1}\\{#2}\\{#3}\\{#4}\end{matrix}} \newcommand{mtxx}[4]{\left[\begin{matrix}\begin{align}&{#1}&\hspace{-20px}{#2}\\&{#3}&\hspace{-20px}{#4}\end{align}\end{matrix}\right]} \newcommand{mtxxx}[9]{\begin{matrix}\begin{align} &{#1}&\hspace{-20px}{#2}&&\hspace{-20px}{#3}\\ &{#4}&\hspace{-20px}{#5}&&\hspace{-20px}{#6}\\ &{#7}&\hspace{-20px}{#8}&&\hspace{-20px}{#9} \end{align}\end{matrix}} \newcommand{amtxxx}[9]{ \amttx{#1}{#4}{#7}\hspace{10px} \amttx{#2}{#5}{#8}\hspace{10px} \amttx{#3}{#6}{#9}} \) \( \newcommand{ph}[1]{\phantom{#1}} \newcommand{vph}[1]{\vphantom{#1}} \newcommand{mtxxxx}[8]{\begin{matrix}\begin{align} & {#1}&\hspace{-17px}{#2} &&\hspace{-20px}{#3} &&\hspace{-20px}{#4} \\ & {#5}&\hspace{-17px}{#6} &&\hspace{-20px}{#7} &&\hspace{-20px}{#8} \\ \mtxxxxCont} \newcommand{\mtxxxxCont}[8]{ & {#1}&\hspace{-17px}{#2} &&\hspace{-20px}{#3} &&\hspace{-20px}{#4}\\ & {#5}&\hspace{-17px}{#6} &&\hspace{-20px}{#7} &&\hspace{-20px}{#8} \end{align}\end{matrix}} \newcommand{mtXxxx}[4]{\begin{matrix}{#1}\\{#2}\\{#3}\\{#4}\end{matrix}} \newcommand{cov}[1]{\t{cov}({#1})} \newcommand{Cov}[1]{\t{cov}\left({#1}\right)} \newcommand{var}[1]{\t{var}({#1})} \newcommand{Var}[1]{\t{var}\left({#1}\right)} \newcommand{pnint}[]{\int_{-\infty}^{\infty}} \newcommand{floor}[1]{\left\lfloor {#1} \right\rfloor} \) \( \newcommand{adeg}[1]{\angle{({#1}^{\t{o}})}} \newcommand{Ree}[]{\mathcal{Re}} \newcommand{Im}[]{\mathcal{Im}} \newcommand{deg}[1]{{#1}^{\t{o}}} \newcommand{adegg}[1]{\angle{{#1}^{\t{o}}}} \newcommand{ang}[1]{\angle{\left({#1}\right)}} \newcommand{bkt}[1]{\langle{#1}\rangle} \) \( \newcommand{\hs}[1]{\hspace{#1}} \)

  UNDER CONSTRUCTION

MATLAB:
Control Systems



\(\ds F(s) = K\frac{40}{[(s+1)^2+9](s-1)(s+4)}\)

Root Locus

num = 40;   

% zeros

den = poly([-4, 1, -1+3j, -1-3j]);

% poles

rlocus(num,den)

% plot root locus of transfer function

set(findall(gca,'Type','line'),'LineWidth',2)

% increase linewidth

H = findall(gca,'Type','line');

% set plot line handler

H(12).LineWidth = 2;

% increase pole marker width

H(12).MarkerSize = 10;

% increase pole marker size

grid

% display polar grid

pbaspect([1 1 1])

% scale display axes equally


Root Locus plot MATLAB
Nyquist Diagram

num = 40; den = poly([-4, 1, -1+3j, -1-3j]);  

% zeros & poles

nyquist(num,den)

% plot nyquist diagram of transfer function

set(findall(gca,'Type','line'),'LineWidth',2)

% increase linewidth

H = findall(gca,'Type','line');

% set plot line handler

H(12).LineWidth = 2;

% increase pole marker width

H(12).MarkerSize = 10;

% increase pole marker size

H(12).Marker = '*';

% change marker for visibility

grid

% display gain contours

pbaspect([1 1 1])

% scale display axes equally


Nyquist Diagram MATLAB

Bode Plot

num = 40;   

% zeros

den = [1 5 12 22 -40];

% poles (alt form)

rlocus(num,den)

% plot root locus of transfer function

H = findobj('Type','Line')

% set plot line handler

H(3).LineWidth = 2; H(4).LineWidth = 2;

% ^ increase linewidth for objects with non-empty data arrays

grid

% display semilog grid


\(\ds F(s) = K\frac{40}{[(s+1)^2+9](s-1)(s+4)}\)

% alt code for system plots

sys = tf(num,den); rlocus(sys); figure(2);

% plot nyquist separately

nyquist(sys); figure(3);

% plot bode separately

bode(sys)

Code for on-command styling of plots as above:
prettyRlocus.m
prettyNyquist.m
prettyBode.m

Bode Plot MATLAB

2nd-Order Systems

function stepOrder2(a,b,K)

%STEPORDER2 Compute & plot step response of second-order system % input arguments (a,b,K), where K = tf. coeff.

'Second-order system impulse response' syms s % construct symbolic object F = (1/s)*K/(s^2+a*s+b);

% define transfer function

'Transfer Function' pretty(F) f=ilaplace(F);

% inverse-Laplace to obtain time response

'2nd-Order Step Response' pretty(f) H = ezplot(f,[0:.01:10]);

% plot f evaluated at 0:.01:10

hold on set(H,'LineWidth',2); title("2nd-Order Step Response",'FontSize',14) xlabel("time"); ylabel("h(t)"); axis('auto'); hold off end
function impulseOrder2(a,b,K)

%IMPULSEORDER2 Compute & plot impulse response of second-order system % input arguments (a,b,K), where K = tf. coeff.

'Second-order system impulse response' syms s % construct symbolic object F = K/(s^2+a*s+b);

% define transfer function

'Transfer Function' pretty(F) f=ilaplace(F);

% inverse-Laplace to obtain time response

'2nd-Order Impulse Response' pretty(f) H = ezplot(f,[0:.01:10]);

% plot f evaluated at 0:.01:10

hold on set(H,'LineWidth',2); title("2nd-order Impulse Response",'FontSize',14) xlabel("time"); ylabel("h(t)"); axis('auto'); hold off end

%ABORDER2 Compute, return, & display second-order system % parameters; input arguments: (a,b) (set before call)

w = sqrt(b); k = a/(2*w); s1 = -k*w + w*sqrt(k^2-1); s2 = -k*w - w*sqrt(k^2-1); T_P = pi/(w*sqrt(1-k^2)); T_s = 4/(k*w); if (k < 1) && (k > 0) e = 2.718281828; OS = string(e^(-k*pi/sqrt(1-k^2))*100) + "%"; clear e; else OS = 'N/A'; end fprintf('\ns1 = %g+j(%g)\n', real(s1), imag(s1)); fprintf('s2 = %g+j(%g)\n', real(s1), imag(s2)); fprintf('k = %g\n', k); fprintf('w = %g\n', w); fprintf('T_P = %g\n', T_P); fprintf('T_s = %g\n', T_s); fprintf('overshoot = %s\n', OS); switch 1 case k == 0; fprintf('\nUndamped System\n'); case (k > 0) && (k < 1); fprintf('\nUnderdamped System\n'); case k == 1; fprintf('\nCritically-damped System\n'); case k > 1; fprint('\nOverdamped System\n'); end
>> stepOrder2(2,9,9)


secondOrder.zip (code files)




Dragon Notes,   Est. 2018     About

By OverLordGoldDragon