Simulink block to get the specified value

Is there a block that can get the initial value or specified value from the signal?
If there is a way to find the value from a specified index, please let me know.

6 Commenti

Can you be a little more descriptive in what you're trying to do?
A
A il 5 Set 2021
Modificato: A il 5 Set 2021
(Figure is an example.)
The goal is to get the initial values of the output signal in real time when the simulation is run.
I want to extract the necessary values from a signal by specifying an index.
Is there a Simulink block that can do this?
All I see is a sine wave going into a scope. I don't understand how that illustrates what you want to do. I assume the "outupt signal" in question is the output of the sine wave block.
Once you "get" the intial value of that sine wave signal, what do you want to do with it? Save it as an output of the simulation? Use it in the simulation while the simulation is running? Something else?
I'm not sure what you mean by "specifying an index" for a signal? Is the signal a scalar or a vector?
The sine wave example was just to show a fluctuating signal. I'm sorry.
This time, I want to get a value from a changing signal, not a fixed value signal like Constant, and use the obtained value in a running simulation. I would like to use it for the input of the block in the picture.
When I wrote "index", I meant the number of data in the signal. It is a scalar signal.
Hi @A,
I'm still confused about what you want to do.
a. "I want to get a value from a changing signal,." Does this mean you want to interogate the value of that signal at a certain time and hold it at that value afterwards?
b. I'm sorry, but I still don't know what "number of data in the signal" means for a scalar signal.
Sorry for the confusion.
a. That's right.I want to take the value of a waveform at a certain time, and use that value (fixed value) as input for another block.
b. I wrote "index" as an image to specify the order of the values, like M rows and N columns. I think the usage is wrong. So, please don't worry about it.
I thought it would be useful if I could specify an arbitrary order of the values, such as getting the first value output from a waveform.

Accedi per commentare.

 Risposta accettata

Paul
Paul il 6 Set 2021
One option to grab the value of a signal at a certain time and hold it afterwards is to pass it through a Triggered Subsystem, where the trigger signal is based on the time you want to grab the value. Like this:

Più risposte (1)

Andy Bartlett
Andy Bartlett il 7 Set 2021
Modificato: Andy Bartlett il 7 Set 2021
You need your design to remember the past value of a signal, so your design will need some lasting memory. Lasting memory is also called state. The simplest way to get memory for a discrete-time model is to use a Unit Delay or Delay block.
You want to latch a signal value at a particular time, so you'll need to create a true/false signal that indicates value true when you want the latching to happened and false at all other times.
You can then use a switch block to control whether the new signal value goes into the delay block or the delay block output is fed back into itself. This figure shows the basic idea where the signal labelled Enable is the true/false control signal.
There is a subtle, but important choice of whether it is OK to get the latched value after one unit delay time step or immediately with zero delay. The image above will involve a one time step delay. If you need zero delay, then change the design to feed the signal labelled Xnew as the output instead of Xold.
Since you want to capture the very first value of the signal, you want an enable signal that is true at the beginning of simulation and always false after that. A constant and the good old unit delay can do this as shown in this image. A key is that the first output of the unit delay is its initial condition which is 1. After that, the delay's output will be its prior input which is always 0.
A model showing both the one time step delay and zero time step delay is attached. It works with R2013a and newer.
Note the delay blocks shown are custom examples and are not the Delay block provided by Simulink. Click to select each block of these custom delay blocks one at a time, then do Crtl-U to look at what is underneath their masks. That will be informative.
The two sets of outputs look like this.
Where the yellow signal is the one to be captured at a specific moment.
The green-ish signal is the true-false control signal for when the latching action is to happen.
The magenta is the captured and held signal.
Note, the sample times for all the blocks are 1 second..

Prodotti

Release

R2021a

Richiesto:

A
A
il 5 Set 2021

Modificato:

il 7 Set 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by