Hello all. I am working with time series data. I have a matrix 142×240000 (142 rows, each row has 240000 columns). I want to calculate the the normalisation weight for each row. Below is the code:
%Normilisation time window width.half of the max period of the bandpass which is applied to the data prior to cross-correlation. (7Hz-40Hz)
N=0.07;%Calculate the size of the signal to get number of columns and rows. n is number of rows and p is number of columns
[n,p] = size(signal);%Calculate the normalised weights
count = 0for j = 1:142 %Matrix indexing, each row representing 10 minutes
count = count + 1; ten = 240000; %Number of columns
%Divide signal into 142 rows and 240000 columns
A(count,:) = signal(((j-1)*ten)+1:ten*j);
The above code runs just fine. It takes the signal that I have and divides it into 142 rows and 240000 columns. I now need to calculate the normalisation weight for each row. In the end, I want to have a matrix called weight with the size 142×1, each row should have the calculated weight of it's corresponding row from matrix A. The formula for calculating weight is:
weight =(1/((2*N)+1))*sum(abs(row)).
The code I have to calculate the weight is:
for i = 1:142 weight(i)=(1/((2*N)+1))*sum(abs(A)); %The A here should be the rows(row1,row2,...till row 142)
end
How do I make the For Loop to calculate the weight from row 1 to row 142 and store the calculated weights as a 142×1 matrix
Best Answer