Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
ICS
ICS Public
Lecture Files
Commits
804e11ed
Commit
804e11ed
authored
May 28, 2021
by
Patrick Göttsch
Browse files
Gitlab Runner Update from lnsi-auxfiles/master:Update cs7_LSparest.m
parent
7021c378
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
41 deletions
+41
-41
LNSI/exercise-files/Problem_1_5/cs7_LSparest.m
LNSI/exercise-files/Problem_1_5/cs7_LSparest.m
+41
-41
No files found.
LNSI/exercise-files/Problem_1_5/cs7_LSparest.m
View file @
804e11ed
% Exercise 7.5 :: Least Squares Identification
%
% TUHH :: Institut for Control Systems :: Control Systems Theory and Design
% Last update: 23.01.200
9
clear
all
clc
load
cs7_LSsysdat
Ts
=
1
;
% sampling time
n
=
3
;
% model order
M
=
mkm
(
y3
,
u3
,
n
);
yn
=
y3
(
n
+
1
:
length
(
y3
));
% FIXME
p
=
pinv
(
M
'*M)*M'
*
yn
;
% get parameters % FIXME
den
=
[
1
p
(
1
:
n
)
'
];
% FIXME
num
=
p
(
n
+
1
:
2
*
n
)
'
;
% FIXME
G
=
tf
(
num
,
den
,
Ts
);
[
p
z
]
=
pzmap
(
G
);
%% Plot simulation results of this model with the other signals
Tfin
=
length
(
u3
)
-
1
;
T
=
(
0
:
Ts
:
Tfin
)
'
;
figure
(
1
)
% step
[
y
,
T
,
x
]
=
lsim
(
G
,
u1
,
T
);
subplot
(
211
),
plot
(
T
,[
y
y1
]),
title
(
'step input : true plant and model'
),
legend
(
'model'
,
'plant'
)
subplot
(
212
),
plot
(
T
,
y
-
y1
),
title
(
'step input : error between true plant and Model'
)
figure
(
2
)
% sin
[
y
,
T
,
x
]
=
lsim
(
G
,
u2
,
T
);
subplot
(
211
),
plot
(
T
,[
y
y2
]),
title
(
'sinusoidal input : true plant and model'
),
legend
(
'model'
,
'plant'
)
subplot
(
212
),
plot
(
T
,
y
-
y2
),
title
(
'sinusoidal input : error between true plant and Model '
)
figure
(
3
)
% white noise
[
y
,
T
,
x
]
=
lsim
(
G
,
u3
,
T
);
subplot
(
211
),
plot
(
T
,[
y
y3
]),
title
(
'white noise input : true plant und Model'
),
legend
(
'model'
,
'plant'
)
subplot
(
212
),
plot
(
T
,
y
-
y3
),
title
(
'white noise input : error between true plant and model'
)
% Exercise 7.5 :: Least Squares Identification
%
% TUHH :: Institut for Control Systems :: Control Systems Theory and Design
% Last update: 23.01.20
1
0
clear
all
clc
load
cs7_LSsysdat
Ts
=
1
;
% sampling time
n
=
3
;
% model order
M
=
mkm
(
y3
,
u3
,
n
);
yn
=
y3
(
n
+
1
:
length
(
y3
));
% FIXME
p
=
pinv
(
M
'*M)*M'
*
yn
;
% get parameters % FIXME
den
=
[
1
p
(
1
:
n
)
'
];
% FIXME
num
=
p
(
n
+
1
:
2
*
n
)
'
;
% FIXME
G
=
tf
(
num
,
den
,
Ts
);
[
p
z
]
=
pzmap
(
G
);
%% Plot simulation results of this model with the other signals
Tfin
=
length
(
u3
)
-
1
;
T
=
(
0
:
Ts
:
Tfin
)
'
;
figure
(
1
)
% step
[
y
,
T
,
x
]
=
lsim
(
G
,
u1
,
T
);
subplot
(
211
),
plot
(
T
,[
y
y1
]),
title
(
'step input : true plant and model'
),
legend
(
'model'
,
'plant'
)
subplot
(
212
),
plot
(
T
,
y
-
y1
),
title
(
'step input : error between true plant and Model'
)
figure
(
2
)
% sin
[
y
,
T
,
x
]
=
lsim
(
G
,
u2
,
T
);
subplot
(
211
),
plot
(
T
,[
y
y2
]),
title
(
'sinusoidal input : true plant and model'
),
legend
(
'model'
,
'plant'
)
subplot
(
212
),
plot
(
T
,
y
-
y2
),
title
(
'sinusoidal input : error between true plant and Model '
)
figure
(
3
)
% white noise
[
y
,
T
,
x
]
=
lsim
(
G
,
u3
,
T
);
subplot
(
211
),
plot
(
T
,[
y
y3
]),
title
(
'white noise input : true plant und Model'
),
legend
(
'model'
,
'plant'
)
subplot
(
212
),
plot
(
T
,
y
-
y3
),
title
(
'white noise input : error between true plant and model'
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment