state space Input port size problems

조회 수: 2 (최근 30일)
Lorenzo
Lorenzo 2024년 5월 23일
답변: Sayan 2024년 5월 27일
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
Sam Chak 2024년 5월 24일
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
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.

카테고리

Help CenterFile Exchange에서 General Applications에 대해 자세히 알아보기

제품


릴리스

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by