controls - how to run a Simulink model in a Matlab M file in this way? -


i have simulink model "mod_sim" in simulink input port "inp" , output port "out". want send inputs model, simulate , take corresponding outputs @ every sampling time "ts". want simulate model in way "n" time steps (in terms of ts).

more specifically, want following implementation:

at given time step "k", have input u(k) (from other source). then, want apply input mod_sim , corresponding output y(k) model. want repeat n time steps.

how can such implementation?

i happy helps.

you need have inputs defined function of time time span of interest in matlab workspace before start simulation.

assuming have t , u defined in matlab workspace, , input port inp @ root level of model, need configure model use u , t inp, described in import data root-level input ports.

once have done that, can run simulation using sim command, making sure 'saveoutput' on in simulation options.

you can repeat exercise n times in for loop example. real key thing having inputs defined in workspace prior starting simulation.

edit based on comments

it sounds want co-simulation, although don't generating u(t), whether it's piece of software or whatever. regardless, have couple of options see it:

  1. write s-function interact other piece of software generating u(t) pulls new value of u @ each time step. quite hard do, lot of software vendors propose form of co-simulation simulink via s-function (e.g. simulationx). see this other question on same topic.

  2. use tcp/ip or udp/ip communicate between simulink , third-party software. instrument control toolbox provides send , receive blocks tcp/ip , udp/ip. tcp/ip supposed more reliable udp/ip, see this comparison.


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -