Simulink block to get the specified value

2 ビュー (過去 30 日間)
A
A 2021 年 9 月 5 日
編集済み: Andy Bartlett 2021 年 9 月 7 日
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 件のコメント
Paul
Paul 2021 年 9 月 6 日
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.
A
A 2021 年 9 月 6 日
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.

サインインしてコメントする。

採用された回答

Paul
Paul 2021 年 9 月 6 日
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:

その他の回答 (1 件)

Andy Bartlett
Andy Bartlett 2021 年 9 月 7 日
編集済み: Andy Bartlett 2021 年 9 月 7 日
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..

カテゴリ

Help Center および File ExchangeSources についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by