Trying to identify certain peaks in a plot

1 view (last 30 days)
I have managed to plot 2 different plots as shown in the below figures.
In this figure, I have added 2 types of data. The yellow corresponds to a reference undamaged specimen, indicated by the presence of the peaks between 10 and 12 (is called backwall echo). The one in red is indicating presence of damage because of the absense of backwall echo and the increased amplitude between 3 and 8.
In this figure the tested specimen has no damage as there is presence of backwall echo.
I'm ot able to figure out a method to categorize and identify the presence of backwall echo from a given data. Please suggest me some methods so that my output correctly determines if there is damage or not (presence of backwall echo or not).
Thanks in Advance.

Accepted Answer

Mathieu NOE
Mathieu NOE on 23 Aug 2022
Edited: Mathieu NOE on 23 Aug 2022
hello
I have reworked your code
check this :
%% Plot of Undamaged Specimen
% na=readmatrix('Default Dataset (4).csv');
% na=readmatrix('Default Dataset (3).csv');
na=readmatrix('Default Dataset (5).csv');
%time
x= na(:,1);
%amplitude
y=na(:,2);
t=0:0.006:12;
D=interp1(x,y,t);
% plot (x,y,t,D);
plot (t,D);
% [v,idx]=findpeaks(D,MinPeakProminence=0.5);
[v,idx]=findpeaks(D,'MinPeakProminence',0.25);
y_threshold = 10;
idx(v>y_threshold)=[];
v(v>y_threshold)=[];
x_threshold=500;
v(idx<x_threshold)=[];
idx(idx<x_threshold)=[];
hold on
scatter(x(idx),v,"y","filled")
%% Plot of Damaged Specimen
nb=readmatrix('Default Dataset (6).csv');
x1= nb(:,1);
y1=nb(:,2);
E=interp1(x1,y1,t); % no need to use u instead of t
hold on
plot (t,E);
% [w,idx]=findpeaks(E,MinPeakProminence=0.5);
[w,idy]=findpeaks(E,'MinPeakProminence',0.25);
y_threshold = 10;
idy(w>y_threshold)=[];
w(w>y_threshold)=[];
x_threshold=500;
w(idy<x_threshold)=[];
idy(idy<x_threshold)=[];
scatter(x(idy),w,"r","filled")
legend('Undamaged Specimen','Peaks of Undamaged Specimen','Tested Specimen','Peaks of Tested Specimen');
hold off
%% Detecting peaks
% Thresholds
xmin_threshold = 10 ;
xmax_threshold = 12 ;
% Remove below min threshold
v(t(idx)<xmin_threshold )=[];
idx(t(idx)<xmin_threshold )=[];
w(t(idy)<xmin_threshold )=[];
idy(t(idy)<xmin_threshold )=[];
% Remove above max threshold
v(t(idx)>xmax_threshold )=[];
idx(t(idx)>xmax_threshold)=[];
w(t(idy)>xmax_threshold )=[];
idy(t(idy)>xmax_threshold)=[];
n=numel(v); % <= here
m=numel(w); % <= here
% if (n>m)
% disp('The specimen is showing characteristics of damage at this site.');
% else
% disp('The specimen is showing no characteristics of damage at this site.');
% end
%% simpler alternative : if m>0 the tested specimen is OK (whatever the n value is)
if (m>0)
disp('The specimen is showing no characteristics of damage at this site.');
else
disp('The specimen is showing characteristics of damage at this site.');
end
  3 Comments
Shruthimol
Shruthimol on 23 Aug 2022
And I was able to understand the change as well. I'm a beginner and it made so much sense now that i read your comments along with the code.
Mathieu NOE
Mathieu NOE on 23 Aug 2022
My pleasure !
Glad you could recognize where I did the mods , as I was a bit lazy on the comments today !
all the best !

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!