lqgcost.m

来自「本书是电子通信类的本科、研究生辅助教材」· M 代码 · 共 17 行

M
17
字号
function f = lqgcost(x)
%LQGCOST Function which returns the difference between the
%	input and the actual output.
%	Returns a measure of the tracking performance of the system.

%	Copyright (c) 1990-94 by The MathWorks, Inc.

K = x(1:5); % The state feedback control matrix
FF = x(6);  % The feedforward gain

set_param('lqgopt/Matrix gain','D',mat2str(K))
set_param('lqgopt/FF Gain','Gain',mat2str(FF))

[t,x,y] = rk45('lqgopt',6);  % Simulate for 6 seconds
y2 = table1([t,y],0:(6/200):6);  % Interpolate over 201 points
f = y2(:,2) - y2(:,1);   % Output minus the input signal 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?