Discussion:
Variable threshold switch simulink
(too old to reply)
Stratox
2008-01-22 15:09:18 UTC
Permalink
Hello,
i would insert a variable instead of a numerical value in the threshold
field of a standard switch.
The issue is that the variable is not defined in the workspace but is
generated from a simulink block.
I've already tried the block "to workspace" but it returns the array
just at the end of the simulation, but I need these values in real time
during the simulation...
Any suggestion?
Thanks in advance

Alessio
Praetorian
2008-01-22 16:11:32 UTC
Permalink
Post by Stratox
Hello,
i would insert a variable instead of a numerical value in the threshold
field of a standard switch.
The issue is that the variable is not defined in the workspace but is
generated from a simulink block.
I've already tried the block "to workspace" but it returns the array
just at the end of the simulation, but I need these values in real time
during the simulation...
Any suggestion?
Thanks in advance
Alessio
Implement the switch condition externally, using Logical / Relational
Operator blocks for instance, and pass a boolean to the switch. The
switch mask can then be set to ~=0.

HTH,
Ashish.
Stratox
2008-01-22 16:20:05 UTC
Permalink
Post by Praetorian
Implement the switch condition externally, using Logical / Relational
Operator blocks for instance, and pass a boolean to the switch. The
switch mask can then be set to ~=0.
Thanks for the answer, it seems to be the only solution!
Dev Shah
2023-05-08 00:14:10 UTC
Permalink
Post by Praetorian
Post by Stratox
Hello,
i would insert a variable instead of a numerical value in the threshold
field of a standard switch.
The issue is that the variable is not defined in the workspace but is
generated from a simulink block.
I've already tried the block "to workspace" but it returns the array
just at the end of the simulation, but I need these values in real time
during the simulation...
Any suggestion?
Thanks in advance
Alessio
Implement the switch condition externally, using Logical / Relational
Operator blocks for instance, and pass a boolean to the switch. The
switch mask can then be set to ~=0.
HTH,
Ashish.
thanks praetorian. didnt know abou the output data type

Fangjun Jiang
2008-01-22 16:16:02 UTC
Permalink
You could use the Relational Operator to compare the two
variables and then use its output to drive a Switch block.
Post by Stratox
Hello,
i would insert a variable instead of a numerical value
in the threshold
Post by Stratox
field of a standard switch.
The issue is that the variable is not defined in the
workspace but is
Post by Stratox
generated from a simulink block.
I've already tried the block "to workspace" but it
returns the array
Post by Stratox
just at the end of the simulation, but I need these
values in real time
Post by Stratox
during the simulation...
Any suggestion?
Thanks in advance
Alessio
Umair Soori
2008-02-02 14:20:03 UTC
Permalink
Hi there,

I have similar problem as u give answer in matlab central


guess you can use sim('model').

First, in your Simulink model, you need to set up the
configuration parameters. Check the input [t u], output
yout and set proper solver and simulation time.

Then, in your m-script, you need to set up value for [t u]
as the input to your simulation model. call sim('model')
you'll get yout in the workspace. That's the output of
your Simulink model.
I have a complex mathematical model in Simulink block (2
inputs and 7 outputs). Currently, I am writing a program
to
control the mathematical model in Matlab script (m-file).
How can I 'convert' or call for the Simulink block from
within the m-file? The model will be running in a 'for'
loop, hence using the input or output workspace is not
practical.
My problem is I hv a complex simulink program and i have to
use my simulink model output in my M-file program, how can
I use yout in my m-file??? bcoz yout is not coming in
workspace...i also try
v = evalin('base', 'yout'); but yout is not in
workspace, same problem

do u have any idea plz help me

Kind Regards
Loading...