[討論] 在simulink function中如何使用lqr指令
小弟我在simulink中matlab function中打了以下程式碼
輸入u為一個數字
輸出Kopt為矩陣
程式碼如下
function Kopt = fcn(u)
A =[-0.2331 0.1635 0 0 0.0075 0;
0.1635 -0.1710 0 0 0 0.0075;
0 0 -0.2257 0.1635 0 0;
0 0 0.1013 -0.1013 0 0;
0.0001 0 0 0 -0.0041 0;
0 0.0001 0 0 0 -0.0041;]
B =1000*[ -0.7884 -2.3757 0;
-0.0053 -0.0053 0;
0.0000 -0.0000 0.0001;
0.0000 0.0000 0;
0.0010 0.0010 0;
0.0010 0.0010 0;]
Ropt=[1.8e8 0 0;
0 1.8e8 0;
0 0 1.8e8;]
Qopt=[u 0 0 0 0 0;
0 1 0 0 0 0;
0 0 1 0 0 0;
0 0 0 1 0 0;
0 0 0 0 0 0;
0 0 0 0 0 0;]
Kopt=lqr(A,B,Qopt,Ropt)
可是系統都會顯示
The function 'lqr' is not supported for standalone code generation.
See the documentation for coder.extrinsic to learn how you can use this
function in simulation.
是在simulink function中
lqr指令不能用嗎
因為小弟把這段程式碼打在一般m file中可以執行
是哪裡有問題呢
小弟願以1000P幣答謝
感謝大家了
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.116.155.120
※ 文章網址: https://www.ptt.cc/bbs/MATLAB/M.1441018671.A.450.html
推
09/01 16:52, , 1F
09/01 16:52, 1F
推
09/03 06:08, , 2F
09/03 06:08, 2F
樓上可是我在一般的M FILE打lqr可以執行欸 是因為simulink內的embedded matlab
function可執行的東西跟一般m file不一樣嗎?
※ 編輯: manflavor (140.116.155.120), 09/03/2015 13:48:32
MATLAB 近期熱門文章
PTT數位生活區 即時熱門文章