The 'ss' class does not support code generation.

10 ビュー (過去 30 日間)
Bavly Atef
Bavly Atef 2023 年 2 月 2 日
コメント済み: Bavly Atef 2023 年 2 月 3 日
I am trying to implement kalman fiter in simulink, so I am using MATLAB function block to get the gains of Kalman filter. But I Can't resolve this error: "The 'ss' class does not support code generation." I attached a photo of my code.

採用された回答

Paul
Paul 2023 年 2 月 3 日
Hi Bavly,
The only two lines in that function (it would be better if you pasted in text, rather than a screen capture) that are not eligible for code generation are the definition of the plant and the call to kalman. The following approach might work
Define a separate m-function on your path
function L = mykalman(A,B,C,D,Q,R)
[kalmf,L] = kalman(ss(A,B,C,D),Q,R);
end
Then the code in the Matlab Fucntion would be:
function [A,B,C,D,L] = fcn(R0,R1,R2,C1,C2,Em,Soc)
coder.extrinsic('mykalman')
% put lines of code here to compute A,B,C,D,Q,R, then
L = mykalman(A,B,C,D,Q,R);
end
Alternatively, you might want to take a look at: Kalman Filter block
  1 件のコメント
Bavly Atef
Bavly Atef 2023 年 2 月 3 日
Great, thanks alot
It worked, but first I had to preinitialize L .

サインインしてコメントする。

その他の回答 (0 件)

製品


リリース

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by