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.
%

 Accepted Answer

Delayline with 3 outputs and 1 input.

8 Comments

Sorry, what do you mean by delayline with 3 outputs and 1 input? How I'm supposed to add the output from the block?
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.
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?
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...
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.
I cannot open the demo because of the new version of Matlab.. Can you downgrade the format to R2015b?
Here is a versions compatible back to R2014b
Thanks a lot Walter for helping me.
I'll study your example and let you know you about my project.
Thanks again.

Sign in to comment.

More Answers (0)

Products

Asked:

on 17 Oct 2016

Commented:

on 26 Oct 2016

Community Treasure Hunt

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

Start Hunting!