statesim.m

来自「solve power flows by gauss seidel method」· M 代码 · 共 20 行

M
20
字号
function [wdot] = statesim(t,w)

% Hadi Saadat, 1998

% Given the solution of the time-varying matrix Riccati equation found
% by the function riccasim, this function solves the state equation in
% conjunction with the optimal control equation.
global A B Q R t0 tf x0

[A,B,Q,R,t0,tf,x0]=system(A,B,Q,R,t0,tf,x0);
n=length(A); nsq=n*n;
s=reshape(w(1:n*n),n,n)';
r=inv(R);
sdot=[s*A+A'*s+Q-s*B*r*B'*s];
wdot=reshape(sdot',1,nsq);
x(1:n)=w(nsq+1:nsq+n);
u=-r*B'*s*x';
xdot=[A*x'+B*u];
wdot(nsq+1:nsq+n)=xdot(1:n);
wdot=wdot';

⌨️ 快捷键说明

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