Gradient Intensity using principal component analysis

1 view (last 30 days)
I have a time series in which I have to detect the time where the gradient intensity is higher.
if true
% Create a time serie example
x = linspace (1,10,50);
noise = sin (2*x*25*(pi/180))
x = x+noise ;
% Calculate the gradient intensity for each point
for i = 1:length(x);
for j = 1:length(x);
Grad (i, j) = (x(i) -x(j)) / abs(i-j);
end
end
% Perform the PCA
COV=nancov(Grad,'pairwise'); % Use of pairwise dut to the presence of NaN
[Vecp,~] = eig(COV);
% Calculate the 1º-4º PC
Q=COV*(Vecp(:,end )); % 1ºPC
Q1=COV*(Vecp(:,end-1 ));% 2ºPC
Q2=COV*(Vecp(:,end-2 ));% 3ºPC
Q3=COV*(Vecp(:,end-3 ));% 4ºPC
% Plot
figure
subplot(211)
plot(x) % Original sign
hold on
xlabel('Time')
ylabel('Intensity')
legend( 'Obs.')
subplot(212)
plot (Q,'.--r') % 1ºPC
hold on
plot (Q1,'.--m') % 2ºPC
plot (Q2,'.--k') % 3ºPC
plot (Q3,'.--c') % 4ºPC
legend ( '1PC', '2PC','3PC','4PC')
xlabel('Time')
ylabel('Arb. Units')
end
Through principal components analysis of the gradient for each point, you can see 1PC (red line) increases the signal in the area of higher gradient (time until 21 until ~ 43). Does anyone have an idea how to do automatically because I have to applied the methodology to various segments of a series. Or what kind of technique to use? Have already tried eg inflection points, adjust to a normal distribution but not with good results for other segments of the series. For better understanding I let an example of the code I am using.
Thank you in advance for any answer.

Answers (0)

Community Treasure Hunt

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

Start Hunting!