-- Bug description --
Make easy version of lqr, lqe, lqg
-- Scilab error message --
-- How to reproduce the bug --
The lqr (linear quadratic regulator) is too hard to use, certainly for students in a class I wanted to introduce it (and probably for me, too). There should be an "easy" option. I think I made a program that works, although I am not confident, since I don't really understand how fullrf works (or want to understand, since it has nothing to do with basic uses of lqr). Here is a sample program, but this should really be encoded INSIDE the lqr function itself.
My apologies if this is already an option inside Scilab. If so, the doc. on lqr needs updating.
There is a similar story for lqe, lqg, although the Kalman filter seems to have some other commands that might make using it easier.
function [K]=lqr0(A,B,Q,R) // easy version of lqr.
// A=dynamics, B=input coupling
Big=sysdiag(Q,R); // Q=state weight, R=input weight
[nr,nc]=size(Q)
[w,wp]=fullrf(Big);C1=wp(:,1:nr);D12=wp(:,nr+1:$);
P=syslin('c',A,B,C1,D12);
[K,X]=lqr(P);
K=-K; // scilab uses opposite sign convention for K
endfunction