state space Input port size problems
1 回表示 (過去 30 日間)
古いコメントを表示
Hello,
I'm trying to replicate a matlab function in simulink and I cant figure how to.
When in matlab the size of the input arguments is not relevant, but when in simulink I can't use the same set of data
Attached are the 2 models, the simulink and matlab
1 件のコメント
Sam Chak
2024 年 5 月 24 日
Hi @Lorenzo
Have you resolved the issue? In the Simulink model, the input to the State-Space block is incorrectly specified. The initial values of the states are also not specified in the State-Space block.
回答 (1 件)
Sayan
2024 年 5 月 27 日
Hi Lorenzo,
I could reproduce your issue. The issue is due to how the value of "delta" is passed to the "State-Space" block. The steps to resolve the issue are as follows:
- The sample time of Simulink model should be the same as it is specified in the MATLAB script, which is 0.01 and change the solver setting to "Fixed-Step".
- The stop time of the Simulink model needs to be the same as the total time mentioned in the script, i.e., 3 seconds.
- The "State-Space" block accepts the input of width, the same as the number of columns in the B and D matrices. In this case, the value of width is 1. You can find the same in the following documentation:
I have modifed the code inside the "MATLAB Function" block which will output the expected input for the "State-Space" block. After the modification I could get the same output as of the MATLAB script.
The modified model is attached herewith. Please run the model after loading the values of A,B,C,D. You can do it by running your MATLAB script followed by the model.
Hope this resolves your issue.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で General Applications についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!