Matlab Function block(Creaed from Simulink) calling an .m script
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Jose Tharayil John
am 17 Sep. 2018
Beantwortet: Oscar Julian Gonzalez Villarreal
am 12 Dez. 2019
Hi,
I m trying to call a .m file from my function block so that I dont initialize the variables each time. But I get an error "This text contains non-empty top-level expressions" and it looks like a script error when I am trying to run the script. My Initialize script just contains only a line a=10; What am I doing wrong? :)
0 Kommentare
Antworten (2)
Zenin Easa Panthakkalakath
am 25 Sep. 2018
Bearbeitet: Zenin Easa Panthakkalakath
am 25 Sep. 2018
There is an easier way to write a few lines of code that needs to be run before the simulation starts. Go to Model Properties > Callbacks > InitFcn and type in your code there.
Have a look at the documentation on Model Callbacks to execute scripts at specified action points: https://www.mathworks.com/help/simulink/ug/model-callbacks.html
0 Kommentare
Oscar Julian Gonzalez Villarreal
am 12 Dez. 2019
That solution is horrendous.
Just imagine the simplest of the scenarios where you had your code in command line using ode45 with scripts like this for a normal vehicule calculating equations of motion. This is the simplest example, and yet you cannot even apply this.
The hell with this. I am going back to ode45. Absolute garbage. 0 points to simulink.
Define_Parameters; %Script with all inertas, masses, etc
Calculate_Equations_Of_Motions; %Script calculating the equations of motion
Calculate_Kinematic_Equations; %Script calculating kinematic dynamics
0 Kommentare
Siehe auch
Kategorien
Mehr zu General Applications finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!