How I can run a simulink model from Python script?
80 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi, I'm trying to write a script in Python that generate number of inputs, and use them as inputs in a Simulink model. My doubt is how to run a Simulink model from Python (I'm working in windows). Could someone help me?
Thanks
2 Commenti
Risposta accettata
Bo Li
il 22 Set 2016
You may consider MATLAB Engine API for Python:
For example:
>>>import matlab.engine
>>>eng = matlab.engine.start_matlab()
>>>eng.sim("vdp")
5 Commenti
Wade
il 9 Apr 2018
I did it in this way:
>> import matlab.engine
>> Matlab = matlab.engine.start_matlab('-desktop')
>> h = Matlab.new_system('NewModelName')
>> s = Matlab.add_block('simulink/Sources/From Workspace',NewModelName+'/DataIn')
>>Matlab.set_param(NewModelName+'/DataIn','Position',matlab.double([150,150,250,250]),nargout=0)
Indhu Priyadharshini Govindasamy
il 13 Gen 2022
I tried in python like you commented before .it is working completely fine but
i want to run the simulink model in C code and Engine Api
I could find any reference for that.Could you please help me?
Più risposte (1)
Meng Zhang
il 1 Dic 2021
how to run the simulnk model just for one step by using MATLAB Engine API?
1 Commento
David
il 19 Gen 2023
Here is an example on how to do this: https://medium.com/@soutrikbandyopadhyay/controlling-a-simulink-model-by-a-python-controller-2b67bde744ee
Vedere anche
Categorie
Scopri di più su Call MATLAB from Python in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!