How to run a simulink model from a matlab file with different inputs each step?
조회 수: 4 (최근 30일)
이전 댓글 표시
I am using someone's simulation to represent a plant for control system development. The algorithms I want to run are quite complex to implement within simulink so I would prefer to do everything from a matlab file.
Is there a way to run this in some type of for loop where at each step I compute the control input in the matlab function and then call the model as a function just to perform a single step update?
I have seen the sim function, but don't see a straightforward way to do this for a step at a time.
댓글 수: 5
Sam Chak
2023년 9월 28일
Hi @Sebastian
Could you please provide a brief description of the type of controller you've designed? It appears to be a state-feedback controller.
inputs_k = controller(system_state)
답변 (1개)
Sam Chak
2023년 9월 28일
Hi @Sebastian
Thank you for your clarifications. Now that we understand your controller has internal state dynamics, it's important to note that the Interpreted MATLAB function does not support modeling Model State Dynamics. If you are working with nonlinear or general dynamic controllers, you might want to consider modeling the controller using the code-level S-function block. While it may have a steeper learning curve for some, as it involves implementing a set of callback methods, it offers the flexibility you need to implement your dynamic controller.
You can find more information and resources on S-functions in the following links:
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!