0
votes

I'm new to Matlab/Simulink but have a requirement to interface with a Simulink model from a piece of software.

At the moment I have created a simple Simulink function 'Inc' which has 1 input to an addition block with a constant 1 and an output. I have used To/From Workspace blocks and can run the simulation over a fixed time using a time/value vector input, such as simin = [0,0;5,0;5,1;10,1].

What I would like to do is run my model continuously? Reading Workspace values in real-time rather than a pre-defined time based vector?

I can't see how to set this up? Can Matlab/Simulink do this?

To summarise, I would like simin and simout to be single values i.e. simin = 1, then with the model running continuously(infinitely) at the next fixed step simout would update to simout = 2. simin changes would be made at the Workspace at varying intervals.

1

1 Answers

3
votes

The short answer is you can't (easily) do that, that's not how Simulink works. The MATLAB workspace is read/accessed at the beginning of the simulation and passed to the Simulink engine, and even if the values in the workspace change before the simulation is finished, this is not taken into account by the Simulink model running.

There are ways to work around this, but if you are a novice to MATLAB & Simulink, be aware that these are fairly advanced techniques, and I would advise to familiarise yourself with Simulink first.

Have a look at these similar questions for suggestions of how to do what you want:

Obviously, you need to change the simulation end time to Inf or some large number.