Incorporating function and script in simulink
Mostrar comentarios más antiguos
I have a function written that is then executed through a separate script file. I am wanting to incorporate this all into Simulink to do some parameter estimation for my model. I am 100% fresh to Simulink and thus am lost on how to best go about accomplishing this. Also, all my constant values are defined in an Excel spreadsheet.
Respuestas (1)
Walter Roberson
hace alrededor de 1 hora
Editada: Walter Roberson
hace 33 minutos
0 votos
You cannot directly execute MATLAB scripts in Simulink.
- you can run MATLAB scripts that invoke Simulink and get back results
- Inside Simulink, you can use MATLAB Function Blocks to invoke a function. That function can call a script.
If the script is more or less setting up a constant environment for the function, then invoking Simulink inside MATLAB might make the most sense. If the script is setting up a variable environment for the function, then MATLAB Function Block might make sense. However, in the case of MATLAB Function block, it might make the most sense to directly code the script as the function to be executed (converting it from a script to a function.)
If your constant values are defined in an Excel spreadsheet, then you would typically use a MATLAB layer to read the spreadsheet and use the values you find there to set model parameters. I show how to do that in https://www.mathworks.com/matlabcentral/answers/1653710-global-variable-in-simulink#comment_2009495
Categorías
Más información sobre Simulink Environment Customization en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!