Using the Kalman Filter block with multiple inputs u.
32 次查看(过去 30 天)
显示 更早的评论
I have state space equations that depend on a B matrix that has 2 columns, corresponding to having 2 inputs to my system, which are in this case two voltage sources. I would like the Kalman filter block to take both of these inputs and produce the full state estimation of the system. I'm encountering issues with the dimensions of the signals though, as the error I'm receiving is that the input dimensions to my Kalman filter must be 2x1, and then a second error stating that the output of the u port is a one dimensional vector with one element.
Is it even possible to use 2 input signals for the Kalman filter block in simulink, or am I messing up the muxing somehow? Any help is appreciated and I've attatched a picture of the sim. Attatched is also my matlab code that runs the sim.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1072285/image.png)
3 个评论
Sam Chak
2022-7-21
Previously, I thought your system is deterministic. Since your system is stochastic, then use the Kalman Filter to estimate the states.
回答(1 个)
Christine Li
2022-7-22
编辑:Christine Li
2022-7-22
Hello,
From your code, it looks the C matrix is 1-by-6, which should be 1-by-5 to be consistent with A and B matrix dimention. More specifically, it looks you have 5 states, 2 inputs and 1 outputs. Since y = Cx + Du, so the C matrix should be in a dimention of [numY by numX] which turns out to be 1 by 5.
For Kalman Filter design with MATLAB and Simulink, here are some references:
You can use MATLAB script to create the state-space model and call 'kalman' to estimate the states. Here is an example: Design Kalman Filter for MIMO Plant
If you are working in Simulink with Kalman Filter block, you just need to make sure the A, B, C, D matrixes and Q,R are consistent in dimention. As for the example shown above, here is the simulink model screenshot you can refer to:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1074470/image.png)
For your model, there are 2 inputs, you can use a mux to combine the inputs. Please notes that Simulink can automatically handle the signal dimentional. Therefore, if your input signal is already multil-dimentional, you can just feed it in the block, as long as the dimention is consistent with A,B,C,D matrix, the model will be good to run.
To debug the dimention issues in Simulink, you can go to toolstrip tab - Debug ->Information Overlays and turn on the "Signal Dimensions".
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1074475/image.png)
Regards,
Christine Li
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!