Signals & Systems


clc
clear all

% Initial Values
P1 = [1, 7, -3, 23];
P2 = [5, 6, 10,];

% Store polynomial (s+2)(s+5)(s+6) as P3 and display the coefficients
P3 = poly([-2,-5,-6]);

% Begin Root Calculations
P4 = [1, 7, 20];
R4 = roots(P4)

P5 = [5, 7, 9, -3, 2];
R5 = roots(P5)

% Begin Symbolic Math
F=sym('(s^2 + 5*s + 6)*(s^2 + 7*s + 10)');
pretty(F)

v = [1, -4, 0, 2, 45];
y = poly2sym(v)
pretty(y)

syms x;
F = x^4 - 4*x^3 + 2*x + 45;
sym2poly(F)

P6 = [3, 15, 0, -10, -3, 15, -40];
P7 = [3, 0, -2, -6];
Psum = P6 + [0, 0, 0, P7]

P8 = conv([0, 1, 7, 10, 9],[1, -3, 6, 2, 1])

num1 = [2, 9, 7, -6];
den1 = [1, 3];
[a1, b1] = deconv(num1, den1)
sys1 = poly2sym(a1)
rem1 = poly2sym(b1)

num2 = [2, -13, 75, 2, -60];
den2 = [1, -5];
[a2, b2] = deconv(num2, den2)
sys2 = poly2sym(a2)
rem2 = poly2sym(b2)

Inverse Laplace Transform

clear all;
clc;

syms s
G1 = (s+2)/((s+3)*(s+4));
pretty(G1)
g1=ilaplace(G1);
pretty(g1)

syms s
G3 = (100*(s + 2))/(s*(s + 1)*(s^2 + 13*s + 36));
pretty (G3)
g3=ilaplace(G3);
pretty(g3)

Feedback & Controls

%% set up
clear all
close all
clc

%% Gain
pos=0.3;
z=((-log(pos))/(sqrt((pi^2) + (-log(pos))^2)));
k1=122;
k2=4.65;
pdom= -2.3159 + 2.3286i;
pdes=2*pdom;
ades=angle((pdes+6)/((pdes+2)*(pdes+3)*(pdes+5)))*(180/pi);

zc=(4.6318-4.6572)/(tan(ades*(pi/180)));
k3=1/abs(((pdes + zc)*(pdes+6))/((pdes+2)*(pdes+3)*(pdes+5)));

%% System
G1=zpk([-0.1],[0 -1 -3 -10],1);
T1=feedback(G1*k1,1);

G2=zpk([-6],[-2 -3 -5],1);
T2=feedback(G2*k2,1);

G3=zpk([-zc -6],[-2 -3 -5],1)
T3=feedback(k3*G3,1)

%% Step
figure
step(T1)

figure
step(T3)

figure
step(T2,'r',T3,'b')
legend('Original','PD Compensated')

Electromechanical Systems

%% Maintenance
clear all
close all
clc

syms n x z s


%% Original Systems, Inputs, and Sampling
Fs1=300;                                        %Sample Frequency 1
Fs2=1000;                                       %Sample Frequency 2
Fs3=100;                                        %Sample Frequence 3
%Yn1=0.5*x(n) + 0.5x(n-1);                      %System EQ Y2(n)
b1=[0.5 0.5];                                   %System 1 Coefficients
%Yn2=0.5*n(n) - 0.5x(n-1);                      %System EQ Y2(n)
b2=[0.5 -0.5];                                  %System 2 Coefficients
%Yn3=(1/4)*(x(n) + x(n-1) + x(n-2) + x(n-3))    %System EQ Y3(n)
b3=[1/4 1/4 1/4 1/4];                           %System 3 Coefficients


%% Frequency Responses
figure
freqz(b1,1,256,Fs1)          %Frequency Response of System 1
title('Low Pass')

figure
freqz(b2,1,256,Fs1)          %Frequency Response of System 2
title('High Pass')

figure
freqz(b3,1,256,Fs2)          %Frequency Response of System 3
title('Band Pass')

%% SP Tool
sptool
a=[1 0 0 0];


%% Spectrums
n=0:999;
x1=8*cos(2*pi*250*n*(1/Fs2) + (pi/3));
x2=8*cos(2*pi*250*n*(1/Fs3) + (pi/3));


%% FDA Tool
fdatool


%% Chirp
f1=200;
f2=2200;
T=10;
fs=8000;
t=0:(1/fs):T;
y=chirp(t,f1,T,f2);
sound(y,fs)

Plots & Graphs

© 2017 - Michael Browne