From: Devdatt Lad on
Hi Matt,

If any input of the Embedded MATLAB (EML) Function block is connected to a
SimEvents block, then you will need to place this EML Function block inside
a Discrete Event Subsystem to ensure correct event-based operation.

Without your model, I cannot be sure what was going on before, and why you
were getting double firing. But my guess is that your Discrete-Event
Subsystem has two input ports. An update at each input port causes the
Discrete-Event Subsystem to execute. Move your Clock block inside the
Discrete Event Subsystem if this is indeed the case, and you will get the
expected behavior.

If not, try using the SimEvents Debugger using:

>> sedebug <your_model_name>

and step through the simulation. You should be able to identify why the
Discrete-Event Subsystem fires twice and not once as expected.

Hope this helps,
Devdatt

--
Devdatt Lad
The MathWorks, Inc.


"Matthew " <mcdmj96(a)yahoo.co.uk> wrote in message
news:i2m01r$7kn$1(a)fred.mathworks.com...
>I think I have solved the problem though. Taking the embedded mathlab
>function from inside the Discrete Event Subsystem seems to have stopped the
>double generation.
>
> So I can conclude that the double generation is due to the operation of
> the Discrete Event Subsystem, although how it managed to cause this error
> I would still be interested in learning so that I don't inadvertently make
> the mistake somewhere else.
>
> Matt


From: Matthew on
"Devdatt Lad" <Devdatt.Lad(a)mathworks.com> wrote in message <i2mpnr$2qe$1(a)fred.mathworks.com>...
>
> Move your Clock block inside the
> Discrete Event Subsystem if this is indeed the case, and you will get the
> expected behavior.
>
> Devdatt Lad
> The MathWorks, Inc.
>

Thanks Devdatt that is exactly what the problem was, however, having moved the clock inside the Discrete Event Subsystem I am now getting an error telling me that the clock has a continuous sample time and needs to be constant/inherited to work within the block.

How do I set the clock to inherent the sample time of the simulation?

I have checked all block parameters and the simulation configuration but can't seem to narrow down where to change it.

I can arrange to send you a simplified version of the model if it helps.

Regards

Matt
From: Matthew on
> How do I set the clock to inherent the sample time of the simulation?
>
> Regards
>
> Matt

I seem to have fixed this one too by using a Digital Clock with inherited sample time rather than the other Simulink clock.

Thankyou everyone for your help

Matt