程序代写代做代考 matlab AI PowerPoint Presentation

PowerPoint Presentation

Topics

Solving system of linear equations
LTIC system zero-input and zero-state response
Solving differential equation: dsolve() function
Signal as a summation of scaled and time delayed impulses ai δ(t-ti)
Impulse response from D.E.
Convolution (translating mathematical definition into a code)
Debugging Matlab code
Matlab inbuilt function: conv()
scaling factor for conv()
Deconvolution: deconv()

System of linear equations
A system of linear equations can be transformed into a matrix equation, making the system easier to solve
can be written the following way:
A system of this type has the form Ax = b
and can be solved in Matlab by x=inv(A)*b or A\b
A=[1 -2 3;-sqrt(3) 1 -sqrt(5); 3 -sqrt(7) 1];
b=[1 pi exp(1)]’; % column matrix
 
X=inv(A)*b
 
X1=A\b
File: solving_linear_equations.m

A
x
b
Ax = b  A-1Ax = A-1b  x =A-1b

2

LTIC system and characteristics differential equation
LTIC system=Linear time invariant causal system

The systems we will cover
in this course are characterized
with differential equations

Causality: No output before the input signal

LTIC system and characteristics differential equation

Complete solution of D.E. = homogeneous solution + particular solution

Homogeneous solution/natural response: system response without inputs
(zero-input solution)
Particular solution/ forced response: system response to different input
(zero-state solution)
Uniqueness of a D.E. solution depends on the boundary values/ initial conditions

Zero-input response and zero-state response
due to charge stored in capacitor
before x(t) was turned on at t=0;
initial condition NOT PART OF
A LINEAR SYSTEM ANALYSIS

A charges capacitor can be treated as linear capacitor with no charge plus a voltage source
vc(0)

C w/o charge

6

Zero-input response and zero-state response

Energy storage element can be treated as linear component with no energy plus a voltage/current source at t=0
System response is superposition of response due to independent sources
External drive x(t) (zero-state response)
Internal drive: initial drive at t=0- (zero-input response)
(causal system)

Zero-input response is not part of linear analysis
t
y
a1t+b
a2t

b
b=zero-input response
input output
x1 y1
x2 y2
x1+x2 y1+y2

A linear system
y=a1t+b does not follow linearity

Fig 2.1a

Zero-input response and zero-state response example

Zero-input and zero-state response initial conditions
Zero-input response:
– all external driving force/source is deactivated
– response due to initial condition of energy storage elements (inductor/capacitor)

KVL for zero-input response at t=0:

initial voltage of capacitor is 5V
initial current in the inductor is 0 A
No source voltage.
y(0) =0 and Dy(0)=-5
Zero-state response:
– all driving force of internal energy storage elements (inductor/capacitor/state variable) is deactivated

KVL for zero-state response at t=0:

No initial capacitor voltage (VC(0)= 0 V)
No initial inductor current IL(0)=y(0)=0 A
Source voltage x(0)=10 V.
y(0) =0 and Dy(0)=10
(D2+3D+2)y(t)=0
(D2+3D+2)y(t)=Dx(t), x(t)=10e-3t

%% zero input response: x=0, from KVL Dy(0)=-5
y_zi=dsolve(‘D2y+3*Dy+2*y=0′,’y(0)=0′,’Dy(0)=-5′,’t’);
disp([‘zero-input response = (‘,char(y_zi),’)u(t)’]);

%% zero state response: vc(0)=0, x=10exp(-3t), Dx=-30exp(-3t) and from KVL Dy(0)=10
y_zs=dsolve(‘D2y+3*Dy+2*y=-30*exp(-3*t)’,’y(0)=0′,’Dy(0)=10′,’t’);
disp([‘zero-state response = (‘,char(y_zs),’)u(t)’]);

In this course we will be solving for zero-state response (linear response)

(causal system)
Open file: solving_zi_and_zs_repsonse.m

Impulse δ(t)
Impulse δ(t) is an useful mathematical definition for handling signals

Sampling property of impulse allow us to express any signal as summation of scaled and time delayed impulses
Sampling property of impulse:

Impulse response h(t), when x(t)=δ(t)
Instead of solving system differential equations for all possible x(t), we solve for x(t)=δ(t)
The response of the system y(t) is impulse response h(t)
The output y(t) of any x(t) will be a linear combination of the signal h(t)

Impulse response h(t), when x(t)=δ(t)
Generic form of system D.E.
We will only consider stable systems where N>M
First solve for Q(D)=0 (homogeneous solution) with special initial condition
The initial conditions for solving impulse response when x(t)=δ(t) is:
y(0) = Dy(0) = D2y(0) = … = D(N-2)y(0) = 0 and D(N-1)y(0) = 1

See ‘Deriving Impulse response from DE.pdf’ for details.

Solution for Q(D)y(t)=0:

(general solution of homogeneous D.E.)
Impulse response: h(t)=P(D)yn(t) u(t)

Here, N=2
So D1y(0)=1 and y(0)=0

Initial condition:

Q(D)y(t)=0

Impulse response example

%% diff eq of system: D2y+ 3Dy+ 2y= Dx, with BC y(0)=0 and vc(0)=5
% impulse response: x=detla(t), B.C. y(0)=0, Dy(0)=1
y_n=dsolve(‘D2y+3*Dy+2*y=0′,’y(0)=0′,’Dy(0)=1′,’t’);

h=diff(y_n);

disp([‘impulse response h(t) = (‘,char(h),’)u(t)’]);

Open file: solving_impulse_response.m
Impulse response example

H
Impulse response h(t) to output signal y(t)

H

See ‘Convolution_Intuitive_Explanation.pdf’ for details.

Graphical convolution x(t)*h(t)

h(t)
t

x(t)
t
1. Given signal, time axis ‘t’

2. Replace the time axis to ‘τ’

3. Τime-reverse one of the signal h(τ)- ->h(τ)

4. Τime-delay h(t-τ) and integrate the overlap

19

Non zero width of convoluted/resultant signal=∑ non-zero width of x(t) and h(t)
Graphical convolution x(t)*h(t)
t

Observation from graphical convolution

y(t) non-zero minima=
non-zero minima of x(t)+
non-zero minima of h(t)

h(t)
t

x(t)
t
y(t) non-zero maxima=
non-zero maxima of x(t)+
non-zero maxima of h(t)
The result is valid within min(tx)+min(th) to max(tx)+max(th) time window

Debugging Matlab code

break-point
debugging starts
from here

evaluates
one line
at a time

gets into
sub-functions while
evaluating a line
e.g., plot()/ user-defined
function
Open file: convolution_runtime.m

Convolution with Matlab built-in function conv()

conv(x,h):
Analytical definition:
Scaling factor for conv(x,h): dT
Correct convolution: conv(x,h)*dT
Matlab does not
keep track of our
time step (dT)

t1x=-1:dT:0-dT;
t2x=0:dT:2;
x1=2*ones(size(t1x));
x2=zeros(size(t2x));
x=[x1 x2];
tx=[t1x t2x];

t1h=-2:dT:0-dT;
t2h=0:dT:1;
t3h=1+dT:dT:2;
h1=zeros(size(t1h));
h2=1-t2h;
h3=zeros(size(t3h));
h=[h1 h2 h3];
th=[t1h t2h t3h];

y=conv(x,h)*dT; % scaling facotor dT
ty=min(tx)+min(th):dT:max(tx)+max(th);
figure
plot(ty,y);

Convolution with Matlab built-in function conv()
Open file: conv_deconv.m

h(1-τ)
h(-τ)
h(-1-τ)
h=deconv(y,x)/dT
Deconvolution (Only in Matlab with limitations)
Scaling factor for deconv(y,x): 1/dT
hh=deconv(y,x)*(1/dT);  % scaling factor (1/dT)
 
t_hh=min(ty)-min(tx):dT:max(ty)-max(tx);
figure
plot(t_hh,hh)
ylim([-.1 1.1]);
legend(‘impulse response h(t)’)

If x[0] is zero(0), we can not do deconvolution 

Deconvolution (Only in Matlab with limitations)

h(1-τ)
h(-τ)
h(-1-τ)
y(1)=0; % no error
x(1)=0; % error !!
hh=deconv(y,x)*(1/dT);  % scaling factor (1/dT)
Error x(1)

vL(0)+ vR(0)+ vC (0) = 0

1.
dy(0)

dt
+ 3y(0)+5V = 0

dy(0)
dt

= −5

v
L
(0)+v
R
(0)+v
C
(0)=0
1.
dy(0)
dt
+3y(0)+5V=0
dy(0)
dt
=-5

vL(0)+ vR(0)+ vC (0) = 10e
−3(t=0) V

1.
dy(0)

dt
+ 3 y(0) = 0⎡⎣ ⎤⎦ + 0V = 10V

dy(0)
dt

= 10

v
L
(0)+v
R
(0)+v
C
(0)=10e
-3(t=0)
V
1.
dy(0)
dt
+3y(0)=0
é
ë
ù
û
+0V=10V
dy(0)
dt
=10

yn(t)= Cie

λit

i

y
n
(t)=C
i
e
l
i
t
i
å

DN + a1D

N−1 + …+ an−1D + an( ) y(t) = b1D M + b2D M−1 + …+ bm−1D + bm( )x(t)

D
N
+a
1
D
N-1
+…+a
n-1
D+a
n
( )
y(t)=b
1
D
M
+b
2
D
M-1
+…+b
m-1
D+b
m
( )
x(t)

y(n) = x( j)h(n− j)

j

y(n)=x(j)h(n-j)
j
å

x(t)∗h(t) = x(t )h(t −t )dt

−∞

∫ = dT x( j)h(n− j)
j

y






=







x






ac

y
é
ë
ê
ê
ê
ù
û
ú
ú
ú
=
é
ë
ê
ê
ê
ê
ù
û
ú
ú
ú
ú
x
é
ë
ê
ê
ê
ù
û
ú
ú
ú
ac

y[n]= h[n]∗ x[n]= x[n− m]h[m]

m=−∞

∞∑

y[n]=h[n]*x[n]=x[n-m]h[m]
m=-¥
¥
å

h[n]=

y[n]− x[n− m]h[m]
m=1

n∑
x[1]

h[n]=
y[n]-x[n-m]h[m]
m=1
n
å
x[1]

/docProps/thumbnail.jpeg