Skip to content
Snippets Groups Projects
Commit 730e9c13 authored by Sebastian Schwarz's avatar Sebastian Schwarz
Browse files

update notebook V02.1.ipynb

parent 774d9d2c
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id: tags:
# <span style='color:OrangeRed'>V2 Z-TRANSFORMATION </span>
%% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Hier vergleichen und überprüfen wir verschiedene Methoden zur Berechnung der Inverse der z-Transformation.
%% Cell type:code id: tags:
``` octave
% Necessary to use control toolbox
pkg load control
clear all
```
%% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Ein bestimmtes Signal wird durch seine z-Transformation beschrieben, für die wir Zähler und Nenner kennen.
%% Cell type:code id: tags:
``` octave
num = [6 0]
den = [1 -4 3]
G = tf(num,den,1)
```
%% Output
num =
6 0
den =
1 -4 3
Transfer function 'G' from input 'u1' to output ...
6 z
y1: -------------
z^2 - 4 z + 3
Sampling time: 1 s
Discrete-time model.
%% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Erste Option ist eine Potenzreihenentwicklung, d.h. wir wenden die Division von Zähler und Nenner mehrfach an:
%% Cell type:code id: tags:
``` octave
k=0:4;
[x(1) r] = deconv(num,den)
for j = 1:4
numnew = conv(r,[1 0])
[p r] = deconv(numnew,den)
x(j+1) = p(length(p))
end
plot(k,x)
```
%% Output
x = 0
r =
6 0
numnew =
6 0 0
p = 6
r =
0 24 -18
x =
0 6
numnew =
0 24 -18 0
p =
0 24
r =
0 0 78 -72
x =
0 6 24
numnew =
0 0 78 -72 0
p =
0 0 78
r =
0 0 0 240 -234
x =
0 6 24 78
numnew =
0 0 0 240 -234 0
p =
0 0 0 240
r =
0 0 0 0 726 -720
x =
0 6 24 78 240
%% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Zunächst beginnen wir mit der Partialbruchzerlegung. In Matlab/Octave gibt es die Funktion <code>residue</code>.
Diese Funktion wird verwendet, um einen Bruch in Terme des Typs a/(z-b) zu zerlegen.
Dann müssen wir zunächst den Zähler durch z dividieren und dann die Funktion verwenden.
%% Cell type:code id: tags:
``` octave
numz = deconv(num, [1 0])
[r,p,q]=residue(numz,den)
```
%% Output
numz = 6
r =
3.0000
-3.0000
p =
3
1
q = [](0x0)
%% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify">
r sind die Koeffizienten für die Zähler, p sind die Pole
das Signal ist dann die Summe von Termen des Typs r*p^k
%% Cell type:code id: tags:
``` octave
npoles = length(p)
for i=1:npoles
s(i,:) = r(i).*p(i).^k
end
```
%% Output
npoles = 2
s =
3.0000 9.0000 27.0000 81.0000 243.0000
s =
3.0000 9.0000 27.0000 81.0000 243.0000
-3.0000 -3.0000 -3.0000 -3.0000 -3.0000
%% Cell type:code id: tags:
``` octave
plot(k,s(1,:),k,s(2,:),k,s(1,:)+s(2,:))
```
%% Output
%% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Wir können das Ergebnis auch mit Hilfe der symbolischen Toolbox überprüfen.
%% Cell type:code id: tags:
``` octave
pkg load symbolic
syms z
F1 = 6*z/(z^2 - 4*z +3)
F2 = partfrac(F1)
```
%% Output
Symbolic pkg v2.9.0: Python communication link active, SymPy v1.5.1.
F1 = (sym)
Symbolic pkg v2.8.0: Python communication link active, SymPy v1.5.1.
%% Cell type:code id: tags:
``` octave
F= 6*z/(z^2-4*z+3)
F1 = F*1/z
G1 = partfrac(F1)
Gs = expand(G1*z)
```
%% Output
F = (sym)
6⋅z
────────────
2
z - 4⋅z + 3
F2 = (sym)
F1 = (sym)
3 9
6
────────────
2
z - 4⋅z + 3
G1 = (sym)
3 3
- ───── + ─────
z - 1 z - 3
Gs = (sym)
3⋅z 3⋅z
- ───── + ─────
z - 1 z - 3
%% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Per Definition ist dies auch die Impulsantwort der Übertragungsfunktion, was wir wiederum mit der Funktion <code>impulse</code> aus Matlab/Octave überprüfen können.
%% Cell type:code id: tags:
``` octave
x2 = impulse(G)
plot(k,x2(1:5))
```
%% Output
x2 =
0
6
24
78
240
726
%% Cell type:code id: tags:
``` octave
```
%% Cell type:code id: tags:
``` octave
```
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment