[MUSIC] So let's calculate some parameters in the moving window for our ECG time series. Firstly we need to create a new script, as usual, and load our dataset. Sampling frequency is equal to 257, and we will take only the third lead. Okay, let's run this part of code. You see, that we obtained a data array with only one column. It corresponds to one lead. Choose the window size in one minute, and we use fix() to round it. Window will be fix(1*Fs). Because if you want to use, for example, half of the minute, we need to obtain normal window for indexes. But here we will have only one minute window. Choose a moving step in 30 seconds, or half a minute. And also we need to calculate the length of our data, Using length() function. Let's run this section. Okay, length is equal to 300,000 and everything is okay without errors, great. To find number of results and values, use the equation n=fix(L-window), And divide it by step size and plus 1. Select, press F9, we obtain that we will have approximately 2,000 steps for calculation. And let's predefine first value for our arrays. We will calculate mean, median, and std value in moving window. So we have first values is for our median dataset, mean value, and standard deviation. Let's run this section. Okay, it will be like initialization of our arrays. After that we will add new values to these arrays. And also, we need to create new variable minID, with some step. And it will be equal to 1. This variable contains number of related data row from statistical signal properties. Index for our properties, arrays and lastID will be 1. We initialize these arrays. And we need to calculate starting indexes for our dataset to calculate mean, and median, and std values. While our lastID less than signal end minus step we need to recalculate our startID. It will be equal to previous startID plus our window minus 1. And so we will calculate next, value of our mean array as mean of our dataset in the range from startID to startID plus step. We have actually lastID here, so let's use lastID. And we forgot to define lastID, It will be equal our startID plus window minus 1. Sorry for mistake here. We have not startID, but here i multiplied by step, sorry. Yes, that's correct. startID is equal to our step number. We predefine it as 1 for our starting calculations. And lastID will be equal to startID plus some shift or window. And we calculate new value of our mean in this string. Don't forget semicolon. Okay, and the same operation we need to repeat for median. And for the std, just copy. And we will have minID, from our startID to lastID in the first column it will be equal i+1, and i=i+1, and end. So, each iteration of these while loop we will add new variables to our arrays. Let's run this section, divide our script to several sections, and add our lastID, lastID=1. Mm-hm. Mm-hm. lastID, where is it? Where is it? Undefined function or variable. Pardon, last, i have some mistake here, but it's normal. So that's great, we have several arrays with calculated mean value, median, and standard deviation. So, We need to add some more values to our minID value, because the length of this array is not equal to the our dataset length. From the end to L, to our first column, it will be i-1. So we just make some link to the last calculations of our mean, median, and standard deviation value. So now this array contains L number of indexes for each signal count. If we open it, you will see that we have our calculations numbers, yes? And for count number, 1,000 for example, Now some error, check L, and we're done. Without sign, yeah. The same number of counts that for our dataset. And for minID in 1,000, we have number 8. It mean that we need to take 8th row from our dataset with calculated parameters, and it corresponds to our 1,000th observation in ECG dat set. Let's plot our data sets, and to visualize the results simultaneously with the original signal indexes use minID, but firstly we need to obtain these calculations. It will be M_ind, for example, minID. So we send our minID as index array. It will be median, it will be S. Median, and S. Mm-hm. What's going on wrong? Yeah, because we defined as 1 to step, Let's open it. Yes, now it will be correct, because we had zero values. I don't know why, actualy, it was something strange, okay. Yes, that's correct. And we may plot our data simultaneously into one figure. Don't forget to use hold on. And for example you may plot M and Median to compare them. Select, and also let's add grid on. Great, so we've plotted simultaneous plot for our data set with calculated indices. And you may see, now we have some difference between median value and mean value. This is because median parameters are more stable for evaluation, and mean is more.. reflect some deviations more than median. So you may use also the same technique to calculate several parameters in moving windows. And create indexes for your data array, and analyze it in combined time grid, in unique time grid. So I hope that it was useful for you.