Retain activation value of relay block in Simulink - simulink

Once a relay block is turned on, it stays on and outputs the current input value. However, I want the input value that originally activated the relay block to continue being the output value (i.e. override the current input value). Thus, the output from the relay block only changes when 1) the relay is switched off or 2) the relay is switched back on according to the specified threshold. Any thoughts on how to do this? Below is my Simulink model (tracking volume of water in a tank and activating a pump to discharge the water when the volume hits a threshhold); my question pertains to the first relay block.

The Relay block outputs the value(s) specified in the block's dialog not the current value of the input. You can achieve what (I think) you're asking by setting the Switch On/Off value to be the same as the Output when On/Off value.

Related

How to store a specific time that a signal value is changed in another parameter in Matlab simulink?

I have two Matlab function blocks that one is producing zero signal for the other. I want to store the exact time that signal changes to one in another parameter in order to use it elsewhere.
How can I do it?
This type of functinality is achieved using a Triggered Subsystem, as per the image below,
The output of the trigger block will take on value of the input (which in this case is the simulation time) every time the trigger signal rises. Look at the parameters of the Trigger block inside the subsystem for other options such as falling edge, or both edge, triggering.

Which input block is used in Matlab simulink that provide random values with time?

I am a new user of Matlab Simulink and currently i am working with Fuzzy Logic Controller with Simulation. In the Simulink, i want to input the values(i highlighted in the picture below), that changes with time.
Here, i am using Uniform Random Number Block which sends four values(which i feed) at same time but i want one value must input first, then another and so on. My target is to use Scope block(the one which is highlighted in the right side) and check the output that varies with time. But with current configuration, i just input ONLY one value. Please help?

Restarting or resetting input signal independently of simulation time and many times

I have designed a signal by using the Signal Builder block in Simulink. During the run of my simulation, the signal builder is to restart depending on the satisfaction of a condition. The condition can be satisfied many times, so, the signal should start from the beginning each time. If I want to put it in another way: You can take step input instead of the designed signal. Step input is to be reset conditionally. How can I make it?
I haven't seen such a functionality built-in Simulink (maybe the newer versions have it?) but here is a workaround:
You can simulate passed time with an integrator that has a Constant block set to 1 as input. The point is that the integrator block has a reset port which you can connect to your condition. So, when your condition becomes true, the integrator restarts a time variable from 0 (which is set in the initial conditions). Beforehand, you need to have your signal saved in something like a Table Lookup block, which outputs the signal as a function of time. Then you connect the integrator output to the Table Lookup block.
Have you tried putting your Signal Builder block in an enabled subsystem? You probably need to set the states when enabling to reset for it to work. Have a look at Create an Enabled Subsystem in the documentation for more details.

How to properly propagate multiplex signal names to scope legend via bus system? (Simulink)

I substituted my originial question, the problem is still the same, but the conditions are now different. To review the original question, have a look at the revisions.
I'm looking for a way to interactively select the signals I want to get displayed in my scope Block. The Bus Selector Block with the property Output as Bus does exactly that. I can select all desired signals conveniently without changing any block or signal dimensions.
But the scope block can obviously not handle properly signal names of buses. Therefore my scope legends are wrong:
If I don't set the Output as Bus property and Mux the signal together into the scope block it displays the right signal names. But this is no option as I'd need to adjust the Mux-dimension according to the signals selected.
Are there any workarounds?
(A Floating Scope is no option either)

How to change the value of simulink block during the simulation?

i have a constant block in a simulink model; i would like to change its value during the simulation when a particular event occurred in a stateflow chart. how can i do it?
If the Stateflow chart output indicates when this event has occurred, or if you can add an additional output that toggles when the event occurs, loop this indicator back (possibly through a Unit Delay block) to the control input of Switch block. The two inputs to the Switch would be two Constant blocks containing the two different values.
If you must do this programmatically without modifying the model, take a look at the reference for the sim command. I should warn you that this may not be trivial to accomplish.
Also, if want to be able to modify the contents of a Constant block mid-simulation (i.e. make it tunable), you may have to turn off Simulink's optimization settings that inline invariant parameters.
You can also add a Slider Gain block between your constant block and the Stateflow block. This would allow you to change the value of the slider gain block during simulation, without the need to change the value of the constant block.