Professional Documents
Culture Documents
Analysis of A Signal
Analysis of A Signal
Analysis of A Signal
load welddefect1_3mm_exp1.mat;
Data = squeeze(features);
Average = mean(Data,3);
%-------------------find peaks
row = size(Average,1);
for ii = 1:row
AfterSmooth(ii,:) = smooth(Average(ii,:));
end
step = 10;
% endpoint = 120;
% [~, FallLocs_n] = findpeaks(AfterSmooth(step,1:endpoint), ...
% 'MinPeakDistance',5, ...
% 'NPeaks', 3,...
% 'SortStr','descend');
%
% RAfterSmooth = -AfterSmooth;
% [~, RiseLocs_n] = findpeaks(RAfterSmooth(step,1:endpoint), ...
% 'MinPeakDistance',5, ...
% 'NPeaks', 3,...
% 'Threshold', 0.01, ...
% 'SortStr','descend');
%
% Locs = [FallLocs_n, RiseLocs_n];
[ValA,A] = max(AfterSmooth(:,1:40)');
[ValB,B] = min(AfterSmooth(:,1:40)');
[ValC,C] = min(AfterSmooth(:,41:65)');
[ValD,D] = max(AfterSmooth(:,41:65)');
% meanA = mean(ValA);
C = C+40;
D = D+40;
ValE = mean(mean(AfterSmooth(:,150:300)'));
E = find(abs(AfterSmooth(:,66:150)'-ValE)<1e-3,1,'first');
E = E + 65;
%--BA gradient-------------
for ii = 1:row
Gradient{ii} = gradient(AfterSmooth(ii,A(ii):B(ii)));
end
%-------------plot-------------
plot(AfterSmooth(1,:));title ('60th step');% original signal
%%-------------------------------------------------------------------------
%%
figure;
plot(B-A);title('BA time')
figure;
plot(C-B);title('AC time')
figure;
plot(D-C);title('DC time')
figure;
plot(E-D);title('ED time')
figure;
for ii = 1:row
plot(Gradient{ii});hold on
end
title('Gradient between AB')
%%
figure;
plot(AfterSmooth(40,:))