How to get 'Data before' and 'Data After' from current data?

Dear all fellow community,
I'm curious about Matlab can read the 'dataBefore' and 'dataAfter' from .mat file with the current data display. I've tried many ways to get the data before and after. The data before and after will be used in the calculation in the 'MATLAB FunctionFever' block. Has anyone done this before?
The picture shows the Simulink block diagram of my work. As you can see in the 'simulation stop time', if I insert the value of 24, the display will display the data that has been stored in sensor1.mat at time=24.
Here is the beginning code that I can do to call the data before and after.
function bbtData = detection(t)
bbtData = t;
end
For more info here I attach my work.
I hope for anyone to assist me in this problem. Thank you.
%

 採用された回答

Walter Roberson
Walter Roberson 2016 年 10 月 17 日

1 投票

Delayline with 3 outputs and 1 input.

8 件のコメント

SyukriY
SyukriY 2016 年 10 月 17 日
Sorry, what do you mean by delayline with 3 outputs and 1 input? How I'm supposed to add the output from the block?
Walter Roberson
Walter Roberson 2016 年 10 月 17 日
You put in a delayline with Mi = 1 (one sample at a time is input) and Mo = 3 (three samples at a time are output). The output will be a vector of three samples, which you can then index into.
This will be the data and the data before and the data before that. To get the data "after", you would probably need to select out the second of the three and use that as if it was your "current" sample.
SyukriY
SyukriY 2016 年 10 月 18 日
Can you show me the example of it?
Here what I've done, but it seems wrong in the Matlab. At first, I try to use the sensor1.mat file, then the first error come out. Then, I try to use constant block and make some number in the discrete form, but still an error. So, I try to create a discrete file in .mat format. Still no luck.
What it's supposed to be looked like?
SyukriY
SyukriY 2016 年 10 月 24 日
What should I do now? I've checked in MathWork Videos and Webinars, there's nothing about showing the 'delay line' block simulink...
Please somebody...
Walter Roberson
Walter Roberson 2016 年 10 月 24 日
Enclosed is a demonstration.
The sensor1.mat was created by
sensor1 = timeseries(1:50,1:2:100);
save sensor1.mat -v7.3 sensor1
The first of the parameters is the time associated with the data in the second parameter.
The input is fed into the Delay Line without an output width of 3. That output is demuxed into three signals, "before", "during", and "after". You would use "during" as your regular input signal. Be careful, the "during" and "after" signals will be 0 until the second or third time step.
I did not figure out how to "step" through values in the file one at a time when the values were not part of a timeseries and had no times associated with them.
SyukriY
SyukriY 2016 年 10 月 26 日
I cannot open the demo because of the new version of Matlab.. Can you downgrade the format to R2015b?
Walter Roberson
Walter Roberson 2016 年 10 月 26 日
Here is a versions compatible back to R2014b
SyukriY
SyukriY 2016 年 10 月 26 日
Thanks a lot Walter for helping me.
I'll study your example and let you know you about my project.
Thanks again.

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

その他の回答 (0 件)

製品

質問済み:

2016 年 10 月 17 日

コメント済み:

2016 年 10 月 26 日

Community Treasure Hunt

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

Start Hunting!

Translated by