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
|
simpars.dt = dt;
## Identification
[epar,Par,Error,Y,iterations,x] = ppp_optimise(system_name,x_0,par_0,simpars,u,y,i_par,Q,extras);
## Do some plots
figure(1);
title("Comparison of data");
xlabel("t");
ylabel("y");
[N,M] = size(Y);
plot(t,Y(:,M-n_y+1:M),"1;Estimated;", t,y,"3;Actual;");
figfig("${sys}_ident_comparison");
## Create a table of the parameters
[n_par,m_par] = size(i_par);
fid = fopen("${sys}_ident_par.tex", "w");
fprintf(fid,"\\\\begin{table}[htbp]\\n");
fprintf(fid," \\\\centering\\n");
fprintf(fid," \\\\begin{tabular}{|l|l|}\\n");
fprintf(fid," \\\\hline\\n");
fprintf(fid," Name & Value \\\\\\\\ \\n");
fprintf(fid," \\\\hline\\n");
for i = 1:n_par
fprintf(fid,"$%s$ & %4.2f \\\\\\\\ \\n", par_names(i,:), epar(i_par(i,1)));
endfor
fprintf(fid," \\\\hline\\n");
fprintf(fid,"\\\\end{tabular}\\n");
fprintf(fid,"\\\\caption{Estimated Parameters}\\n");
fprintf(fid,"\\\\end{table}\\n");
fclose(fid);
endfunction
EOF
}
make_ident_numpar() {
echo Creating ${ident_numpar_file}
cat > ${sys}_ident_numpar.m <<EOF
|
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
|
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
145
146
147
148
149
150
151
152
153
154
|
simpars.dt = dt;
## Identification
[epar,Par,Error,Y,iterations,x] = ppp_optimise(system_name,x_0,par_0,simpars,u,y,i_par,Q,extras);
## Do some plots
figure(1);
grid;
title("Comparison of data");
xlabel("t");
ylabel("y");
[N,M] = size(Y);
y_est = Y(:,M-n_y+1:M);
plot(t,y_est,"1;Estimated;", t,y,"3;Actual;");
figfig("${sys}_ident_comparison");
figure(2);
[n_par,m_par] = size(Par);
grid;
title("Parameter estimates");
xlabel("Iteration");
ylabel("Estimates");
plot(0:m_par-1, Par, 0:m_par-1, Par,"x");
figfig("${sys}_ident_pars");
## Create a table of the parameters
[n_par,m_par] = size(i_par);
fid = fopen("${sys}_ident_par.tex", "w");
fprintf(fid,"\\\\begin{table}[htbp]\\n");
fprintf(fid," \\\\centering\\n");
fprintf(fid," \\\\begin{tabular}{|l|l|}\\n");
fprintf(fid," \\\\hline\\n");
fprintf(fid," Name & Value \\\\\\\\ \\n");
fprintf(fid," \\\\hline\\n");
for i = 1:n_par
fprintf(fid,"$%s$ & %4.2f \\\\\\\\ \\n", par_names(i,:), epar(i_par(i,1)));
endfor
fprintf(fid," \\\\hline\\n");
fprintf(fid,"\\\\end{tabular}\\n");
fprintf(fid,"\\\\caption{Estimated Parameters}\\n");
fprintf(fid,"\\\\end{table}\\n");
fclose(fid);
## Save the data for later use.
par_values = epar(i_par(:,1));
save ${sys}_ident_est_data.dat y_est Y par_names par_values
endfunction
EOF
}
make_ident_numpar() {
echo Creating ${ident_numpar_file}
cat > ${sys}_ident_numpar.m <<EOF
|