我使用这个功能:
function dXdt = mRiccati(t,X,A,B,R,Q)
X = reshape(X, size(A)); %Convert from "n^2"-by-1 to "n"-by-"n"
dXdt = A.'*X + X.*A - X*B.*inv(R).*B'.*X + Q; %Determine derivative
dXdt = dXdt(:); %Convert from "n"-by-"n" to "n^2"-by-1
我的程序是:
% diff equat
R=0.1*eye(3,3);
Q=eye(3,3);
B=1/2.*[0,0.3604,-0.4397;-0.3604,0,0.2226;0.4397,-0.2226,0]+0.8224*eye(3,3);
X0 = [1; 1; 1; 1;1;1];
[T X] = ode45(@(t,X)mRiccati(t,X,A,B,R,Q), [0 10], X0)
它返回此消息错误:
使用重塑
时出错要重新调整元素的数量,不得更改。