-
Notifications
You must be signed in to change notification settings - Fork 1
/
slwidemo3.m
144 lines (93 loc) · 3.3 KB
/
slwidemo3.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
echo on,
% This demonstration example uses the heat exchanger example,
% stored in the DAISY collection,
% available from http://www.esat.kuleuven.ac.be/sista/daisy
% There are one input and one output. The number of data
% samples is 4000.
echo off
% RELEASE 2.0 of SLICOT System Identification Toolbox.
% Based on SLICOT RELEASE 5.7, Copyright (c) 2002-2020 NICONET e.V.
%
% V. Sima 30-03-2002.
%
% Revisions: 04-03-2009.
%
close all
echo on
global pause_wait % This could be used in pause(n) command.
% If pause_wait < 0, standard command pause is used (default).
% Any key should then be pressed to continue.
global no_loop_plot % Set no_loop_plot = 1 to suppress plotting trajectories
% in the model finding loop.
if ~exist('pause_wait', 'var') || isempty(pause_wait), pause_wait = -1; end
% Load the input-output data:
load exchanger_dat;
u = exchanger_dat(:,2); y = exchanger_dat(:,3);
if pause_wait < 0, pause, else pause(pause_wait), end
% Plot the input-output data:
plot_yu(y,u)
% Detailed plot for the first 1000 samples:
plot_yu(y(1:1000,:),u(1:1000,:))
% Find a model based on all data using slmoen4 (alg = 2).
% The order 6 is used.
alg = 2; s = 15; n = 6; [sys,K,rcnd,R] = slmoen4(s,y,u,n,alg);
if pause_wait < 0, pause, else pause(pause_wait), end
% Assess the model:
[err(1),ye] = find_err(y,u,sys);
if pause_wait < 0, pause, else pause(pause_wait), end, close(gcf)
% Plot the estimated output, without predictor:
plot_ye(y,ye);
% Estimate the parameters of a Wiener system, using a neural network
% with nn = 12 neurons to model the nonlinear part.
% Default options (except for nprint) and the MINPACK-like,
% structure-exploting Levenberg-Marquardt algorithm are used.
% The error norm is printed in the file IB03BD.prn
nn = 12; nprint = 1;
if pause_wait < 0, pause, else pause(pause_wait), end
echo off
est_set = 1 : size(y,1)/2;
ur = u; yr = y;
ns = max( size( est_set ) );
u = u(1:ns, :);
y = y(1:ns, :);
dex_wident
echo on
if pause_wait < 0, pause, else pause(pause_wait), end
echo off
if nprint == 1 && exist('IB03BD.prn', 'file') == 2,
% Plot the error norm
errnrm = textread('IB03BD.prn','%*s%*s%*s%*s%*s%f',-1);
figure
set(axes,'FontSize',14)
plot( errnrm, 'b' );
title( 'Error norm trajectory in the optimization process' )
end
% Now, use the Cholesky-based Levenberg-Marquardt algorithm.
% The error norm is printed in the file IB03AD.prn
if pause_wait < 0, pause, else pause(pause_wait), end
echo off
dex_widentc
echo on
if pause_wait < 0, pause, else pause(pause_wait), end
echo off
if nprint == 1 && exist('IB03AD.prn', 'file') == 2,
% Plot the error norm
errnrm = textread('IB03AD.prn','%*s%*s%*s%*s%*s%f',-1);
figure
set(axes,'FontSize',14)
plot( errnrm, 'b' );
title( 'Error norm trajectory in the optimization process' )
end
echo on
if pause_wait < 0, pause, else pause(pause_wait), end
% Now, use default options and the Conjugate Gradients-based
% Levenberg-Marquardt algorithm.
ialg = 2;
if pause_wait < 0, pause, else pause(pause_wait), end
echo off
dex_widentc
echo on
if pause_wait < 0, pause, else pause(pause_wait), end
echo off
% Reset ialg
ialg = [];