Skip to content
Snippets Groups Projects
Commit c69753d1 authored by zhiyupan's avatar zhiyupan
Browse files

add exam example/V1, V2 and V3

parent 3ad2eeb1
Branches
Tags v0.1.1
No related merge requests found
%% Cell type:markdown id:04105e65-6705-4c92-a009-48c54bd38ad4 tags:
# <span style='color:OrangeRed'>V1 DAS ABTASTTHEOREM </span>
%% Cell type:markdown id:ffe7d73f-7986-44b6-a9fd-a678b9aaa182 tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Hier wird analysiert, wie man die geeignete Abtastfrequenz für ein bestimmtes System auswählt. Am Ende überprüfen wir das Ergebnis mit einer einfachen Simulation.
Es ist das folgende System in Form einer Übertragungsfunktion gegeben
%% Cell type:code id:3a336fb9-2f73-44ce-ab67-91b96ccfc1c1 tags:
``` octave
% Necessary to use control toolbox
pkg load control
clear all
```
%% Cell type:markdown id:53866cc1-a0ea-4d77-8d9c-c8345704d874 tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Es ist das folgende System in Form einer Übertragungsfunktion gegeben
%% Cell type:code id:a0b9d775-f176-483e-aaca-43da284aa2e4 tags:
``` octave
num = [100]
den = [1 10 100]
G = tf(num,den)
```
%% Output
num = 100
den =
1 10 100
Transfer function 'G' from input 'u1' to output ...
100
y1: ----------------
s^2 + 10 s + 100
Continuous-time model.
%% Cell type:markdown id:1cb98bc6-138b-45bc-9178-74f8493d4171 tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Berechnet man die Nullstellen des Nenners, erhält man die Pole des Systems
%% Cell type:code id:03459a21-1072-416b-a04b-5de7b9a30813 tags:
``` octave
p = roots(den)
```
%% Output
p =
-5.0000 + 8.6603i
-5.0000 - 8.6603i
%% Cell type:markdown id:071800da-0e16-4189-bb65-5746c0415165 tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Aus den Polen berechnen wir die Zeitkonstanten
%% Cell type:code id:5adb101b-4286-428a-a4bd-eeb57e860e9c tags:
``` octave
tau = -1/real(p)
```
%% Output
tau =
0.100000 0.100000
%% Cell type:markdown id:eae75561-2795-400d-802d-f649281ff316 tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify">
und aus den Zeitkonstanten die Eigenfrequenzen
%% Cell type:code id:acf57137-23eb-4be3-87ef-eb9d08076f07 tags:
``` octave
om = 2*pi./tau
```
%% Output
om =
62.832 62.832
%% Cell type:markdown id:ab36a55a-6239-4214-9d36-85f4d111c61e tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify">
die minimale Abtastfrequenz ist durch das Zweifache der maximalen Eigenfrequenz des Systems gegeben
%% Cell type:code id:c4c1fce4-7677-40d3-813e-5a5e4758f00f tags:
``` octave
minomt = 2*max(om)
```
%% Output
minomt = 125.66
%% Cell type:markdown id:c5fb33ea-47d7-49bf-a8ce-f1d81917a1d0 tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Wir wählen dann einen Wert, der größer ist als das Minimum durch den Koeffizienten K
%% Cell type:code id:14c39a24-fc50-4924-8075-84125990776f tags:
``` octave
K = 2
omt = K*minomt
```
%% Output
K = 2
omt = 251.33
%% Cell type:markdown id:25ea2215-45ca-4980-a862-372d0eccf237 tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Schließlich testen wir die Wahl der Abtastzeit, indem wir die Sprungantwort simulieren und den Ausgang abtasten
%% Cell type:code id:578daff8-f4fd-4001-bb09-aea89d809eec tags:
``` octave
addpath("./Octsim");
tini = 0 # Start time
tfinal = 3 # End time
dt = 0.001 # Time Step
nflows = 3 #Number of data flows in the schematic, Zahlenwert entspricht nicht dem in Matlab (hier um 1 größer)
Ts = 2*pi/omt # Sampling time for discrete time
c1{1} = StepSource(1,0,1,0.1); #StepSource(self,out,startv,endv,ts)
c1{2} = TransferFunction(1,2,num,den); #TransferFunction(self,inp,out,num,den)
c1{3} = DTTransferFunction(2,3,1,1,Ts); #DTTransferFunction(self,inp,out,num,den,Ts)
% Instance of the simulation schematic
sc1 = Schema(tini,tfinal,dt,nflows);
sc1.AddListComponents(c1);
% Run the schematic and plot
out1 = sc1.Run([1 2 3]);
plot(out1(1,:),out1(2,:),out1(1,:),out1(3,:),out1(1,:),out1(4,:));
```
%% Output
tini = 0
tfinal = 3
dt = 0.0010000
nflows = 3
Ts = 0.025000
%% Cell type:code id:9e1a668f-07ac-442a-bb62-950dacd49832 tags:
``` octave
```
%% Cell type:code id:65f46b62-e607-456a-80b6-42f452d0abfc tags:
``` octave
```
File added
%% Cell type:markdown id:04105e65-6705-4c92-a009-48c54bd38ad4 tags:
# <span style='color:OrangeRed'>V3 STABILTÄT DISKRETER SYSTEME </span>
%% Cell type:markdown id:ffe7d73f-7986-44b6-a9fd-a678b9aaa182 tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Wir analysieren hier die Stabilität von diskreten Systemen mit zwei Methoden: Jury und w. Am Ende validieren wir die Ergebnisse mit einer Sprungantwort. Wir betrachten nur ein System zweiter Ordnung
%% Cell type:code id:3a336fb9-2f73-44ce-ab67-91b96ccfc1c1 tags:
``` octave
% Necessary to use control toolbox
pkg load control
clear all
```
%% Cell type:markdown id:53866cc1-a0ea-4d77-8d9c-c8345704d874 tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Es ist das folgende System in Form einer Übertragungsfunktion gegeben
%% Cell type:code id:a0b9d775-f176-483e-aaca-43da284aa2e4 tags:
``` octave
a1 = 1
a2 = 2
b1 = 0.1
b2 = 0.2
num = [a1 a2]
den = [1 b1 b2]
G = tf(num,den, 1)
```
%% Output
a1 = 1
a2 = 2
b1 = 0.10000
b2 = 0.20000
num =
1 2
den =
1.00000 0.10000 0.20000
Transfer function 'G' from input 'u1' to output ...
z + 2
y1: -----------------
z^2 + 0.1 z + 0.2
Sampling time: 1 s
Discrete-time model.
%% Cell type:markdown id:1cb98bc6-138b-45bc-9178-74f8493d4171 tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Berechnet man die Nullstellen des Nenners, erhält man die Pole des Systems
%% Cell type:code id:03459a21-1072-416b-a04b-5de7b9a30813 tags:
``` octave
p = roots(den)
q = abs(p)
```
%% Output
p =
-0.05000 + 0.44441i
-0.05000 - 0.44441i
q =
0.44721
0.44721
%% Cell type:markdown id:071800da-0e16-4189-bb65-5746c0415165 tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Die Pole müssen sich im Inneren des Einheitskreises befinden. Das bedeutet, dass die Werte von q kleiner als 1 sein müssen
%% Cell type:markdown id:c9e8bd3b-e932-4710-9a6a-220f67d882e9 tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Dann wenden wir das Jury-Kriterium an. Zuerst bewerten wir die Funktion in 1 und -1
%% Cell type:code id:5adb101b-4286-428a-a4bd-eeb57e860e9c tags:
``` octave
F1 = 1+b1+b2
Fm1 = 1-b1+b2
```
%% Output
F1 = 1.3000
Fm1 = 1.1000
%% Cell type:markdown id:eae75561-2795-400d-802d-f649281ff316 tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify">
F1 und Fm1 müssen positive sein
%% Cell type:markdown id:fb81055e-1e14-4401-afb2-f90884c549be tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Die letzte Bedingung ist, dass der Betrag von a2 kleiner als 1 sein muss.
%% Cell type:code id:acf57137-23eb-4be3-87ef-eb9d08076f07 tags:
``` octave
pkg load symbolic
syms z
syms w
F1 = (a1*z+a2)/(z^2 + b1*z +b2)
F2 = subs(F1,z,(1+w)/(1-w))
simplify(F2)
```
%% Output
Symbolic pkg v2.9.0: Python communication link active, SymPy v1.5.1.
warning: passing floating-point values to sym is dangerous, see "help sym"
warning: called from
double_to_sym_heuristic at line 50 column 7
sym at line 379 column 13
mtimes at line 63 column 5
warning: passing floating-point values to sym is dangerous, see "help sym"
warning: called from
double_to_sym_heuristic at line 50 column 7
sym at line 379 column 13
plus at line 61 column 5
F1 = (sym)
z + 2
───────────
2 z 1
z + ── + ─
10 5
F2 = (sym)
w + 1
2 + ─────
1 - w
─────────────────────────
2
1 w + 1 (w + 1)
─ + ────────── + ────────
5 10⋅(1 - w) 2
(1 - w)
ans = (sym)
⎛ 2 ⎞
10⋅⎝w - 4⋅w + 3⎠
─────────────────
2
11⋅w + 16⋅w + 13
%% Cell type:markdown id:56641183-2cb4-48c2-b61d-7f612a56d0a7 tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Alle Zeichen im Nenner müssen positiv sein.
%% Cell type:markdown id:ab36a55a-6239-4214-9d36-85f4d111c61e tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Zum Schluss überprüfen wir die Ergebnisse mit der Simulation einer Sprungantwort
%% Cell type:code id:578daff8-f4fd-4001-bb09-aea89d809eec tags:
``` octave
addpath("./Octsim");
tini = 0 # Start time
tfinal = 20 # End time
dt = 0.1 # Time Step
nflows = 2 #Number of data flows in the schematic, Zahlenwert entspricht nicht dem in Matlab (hier um 1 größer)
Ts = 1 # Sampling time for discrete time
c1{1} = StepSource(1,0,1,0.1); #StepSource(self,out,startv,endv,ts)
c1{2} = DTTransferFunction(1,2,num,den,Ts); #DTTransferFunction(self,inp,out,num,den,Ts)
% Instance of the simulation schematic
sc1 = Schema(tini,tfinal,dt,nflows);
sc1.AddListComponents(c1);
% Run the schematic and plot
out1 = sc1.Run([1 2]);
plot(out1(1,:),out1(2,:),out1(1,:),out1(3,:));
```
%% Output
tini = 0
tfinal = 20
dt = 0.10000
nflows = 2
Ts = 1
%% Cell type:code id:9e1a668f-07ac-442a-bb62-950dacd49832 tags:
``` octave
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment