Analysis of A Signal

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

clear;clc

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

%%-------------------------------------------------------------------------
%%

plot([A(1) B(1) C(1) D(1) E(1)],[ValA(1) ValB(1) ValC(1) ValD(1)


ValE(1)],'bo');hold on

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,:))

You might also like