Sunteți pe pagina 1din 12

MATLAB support QA001 29/05/2019 04:13:15.

Question: The Question Originator asks how to start a MATLAB simulation for the research article

Guided Waves for monitoring of plate structures with linear cracks of variable length

authors B. Zima beazima@pg.gda.pl M. Rucka mrucka@pg.gda.pl , at Gdansk University Mechanical Engineering department.

Permission by the authors of the research paper has been granted to publish this text in the following web page:
https://jgb2012.wixsite.com/microwave-eng-matlab/matlab001-ellipses-to-detect-cracks

Background:

The location of a
damage slot of the
figure on the right
hand side is to be
found with a set of
sensors:

fig1

The choice of curves by the authors of the


research paper for triangulation of damage
points on apparently flat metal sheets are
ellipses, not circles.

fig2
By damage point it's understood that it may go from slight scratch to through perforation.

The threshold on bounced back signals is assumed to be correct, and the possible scatter from the edges of the metal sheet
is also assumed to be solved.

The question why ellipses and not just circles are used should be addressed to the authors of the research paper.

_________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com https://jgb2012.wixsite.com/microwave-eng-matlab 1 / 12
MATLAB support QA001 29/05/2019 04:13:15.

Answer:

The following script

1. generates a
randomly located
damage slot with
random length and
tilt angle
2. then prompts for NS
sensor positions
with direct mouse
clicks of the sensors
3. calculates
histograms
equivalent to the
graphs closing point
3 of the research
article.

fig3

The resulting histograms are the ellipse


points of the research article part 3 closing
figures, shown here in the figure on the
right hand side, lined up and piled up
according to same angle.

Yet the histogram peaks may not have the


same location of the narrow area where all
ellipses from all sensors should coincide to
pin-point the target.

Such area of coincidence of all ellipses


generated by all sensors is highlighted by
the overlap graphs closing part 3 of the
research article.

fig4

_________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com https://jgb2012.wixsite.com/microwave-eng-matlab 2 / 12
MATLAB support QA001 29/05/2019 04:13:15.

% ASSUMPTIONS
% homogeneous metal
% single scratch
% sensors do not overlap
% no sensor right on scratch, this is why manual input of sensor locations
% here d=dt*cg in Zima Rucka app note

% DEFINE PLATE
clear all;clc;close all

hf1=figure(1);grid on
ax1=hf1.CurrentAxes
ax1.DataAspectRatio=[1 1 1]

hold all

x_span=100;y_span=50 % half size of [0 0] centred workspace


x_res=.1 % spatial resolution, on both x ad y

x_range=[-x_span:x_res:x_span] % test area


y_range=[-y_span:x_res:y_span]

plot([x_range(1) x_range(end) x_range(end) x_range(1) x_range(1)],...


[y_range(1) y_range(1) y_range(end) y_range(end) y_range(1)],...
'LineWidth',2,...
'Color','b')

ax1.XTick=[x_range(1):10*x_res:x_range(end)]
ax1.YTick=[y_range(1):10*x_res:y_range(end)]

% SIMULATE DAMAGE
Nd=randi([3 25],1,1) % let the damage be a single straight scratch of random length range [5 25]

d_ang_res=2*pi/360 % let be the scratch attitude a random angle with resolution 1 degree
d_ang_range=[0:d_ang_res:2*pi-d_ang_res];
d_ang_target=d_ang_range(randi(numel([d_ang_range]),1,1))

x_d=x_range(randi(numel(x_range),1,1)) % plate damage location


y_d=y_range(randi(numel(y_range),1,1))

plot([x_d-Nd*x_res x_d+Nd*x_res],[y_d-Nd*x_res y_d+Nd*x_res],...


'LineWidth',1,...
'Color','k')

S=.1*floor(10*[x_d-Nd*x_res:x_res:x_d+Nd*x_res;y_d-Nd*x_res:x_res:y_d+Nd*x_res]) % scratch points

NS=5 % amount sensors, there are NS sensors

% x_s=x_range(randi(numel(x_range),1,NS)) % sensors locations


% y_s=y_range(randi(numel(y_range),1,NS))

% INPUT SENSORS
disp(['Place sensors with mouse: ' ' sensors.'])
p_s=ginput(NS)

plot(p_s(:,1),p_s(:,2),...
'LineStyle','none',...
'Marker','o',...
'MarkerSize',4,...
'MarkerEdgeColor',[.5 .5 .5],...
'MarkerFaceColor',[1,0.3921,0])

% round p_s
% pending
% just for plotting purpose, add safety frame on x axis max(x_s(i),x_d) and y axis max(y_s(i),y_d)
% pending

% MEASURE DISTANCES
L=combnk([1:1:NS],2) % L contains all possible combinations of paired sensors

x_c=[];y_c=[];phi=[]

for k=1:1:size(L,1)
pair_1=L(k,1); pair_2=L(k,2)
x_1=p_s(pair_1,1); y_1=p_s(pair_1,2)
x_2=p_s(pair_2,1); y_2=p_s(pair_2,2)
x_c=.5*(x_1+x_2); y_c=.5*(y_1+y_2)

_________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com https://jgb2012.wixsite.com/microwave-eng-matlab 3 / 12
MATLAB support QA001 29/05/2019 04:13:15.

% ell(k).p1=[x_1 y_1] % update ell centres, no needed


% ell(k).p2=[x_2 y_2]
ell(k).centroid=[x_c y_c] % update ell centroid (mid point between ell centres)

c_dist=.5*((x_1-x_2)^2+(y_2-y_2)^2)^.5 % update ell c distance (half distance between ell centres)


% same as pdist([x_1 x_2;y_1 y_2]')
ell(k).c_dist=c_dist

plot([x_1 x_2],[y_1 y_2]) % check

phi0=atan((y_2-y_1)/(x_2-x_1)) % update ell attitude = angle phi


if phi0<0 phi0=2*pi+phi0; end
% phi0/(2*pi)*180 % check
ell(k).phi=phi0

d=[]
for q=1:1:size(S,2)
d=[d ((S(1,q)-x_1)^2+(S(2,q)-y_1)^2)^.5+((S(1,q)-x_2)^2+(S(2,q)-y_2)^2)^.5]
% d is like in bistatic radar: wave travels from p1 [x_1 y_1] to target (scratch) and then to p2 [x_2 y_2]
% this d Zima Rucka app note dt*cg
% d=[d pdist([S(1,q) x_1;S(2,q) y_1]')+pdist([S(1,q) x_2;S(2,q) y_2]')] % same as above line
plot([x_1 S(1,q) x_2],[y_1 S(2,q) y_2],'r-') % check
end

ell(k).d=d

a=d/2 % ell major set of axes for given ell generated for pair of sensors
ell(k).a=a

b=(a.^2.-c_dist.^2).^.5 % ell minor axes


ell(k).b=b

end
plot([x_d-Nd*x_res x_d+Nd*x_res],[y_d-Nd*x_res y_d+Nd*x_res],...
'LineWidth',1,...
'Color','k')

% APPROXIMATING TARGET WITH ELLIPSE POINTS


% d_ang_res2=d_ang_res/10 % you need very accurate angle resolution, or you lose
% resolution when target not orbiting, this is, when approaching or departing
% When sensors too far, aliases show up

d_ang_res2=180/(2*pi)*d_ang_res
ang2=[0:d_ang_res2:360-d_ang_res2]

x=[];y=[];
for k=1:1:size(L,1)
x=[x ell(k).centroid(1)+(ell(k).a)'.*cosd(ang2).*cosd(180/(2*pi)*ell(k).phi)-(ell(k).b)'.*sind(ang2).*sind(180/(2*pi)*ell(k).phi)];
y=[y ell(k).centroid(2)+(ell(k).a)'.*cosd(ang2).*sind(180/(2*pi)*ell(k).phi)+(ell(k).b)'.*sind(ang2).*cosd(180/(2*pi)*ell(k).phi)];
end
figure(2);histogram(x);title('histogram(x)');grid on
figure(3);histogram(y);;title('histogram(y)');grid on
scr1

_________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com https://jgb2012.wixsite.com/microwave-eng-matlab 4 / 12
MATLAB support QA001 29/05/2019 04:13:15.

The obtained histograms, centre, with


command histogram centre with default
bins, and on right hand side with amount
bins equal to spatial resolution.

The histograms on the left correspond to


a different damage slot than the
histograms on the right hand side.

When excessive scattering of sensors


takes place, this is, not keeping them in
tight formation, such lay-out produces
more histogram peaks, and some peaks
corresponding to apparent targets may
be even higher than the actual location of
the damage slot.
fig5

fig6

_________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com https://jgb2012.wixsite.com/microwave-eng-matlab 5 / 12
MATLAB support QA001 29/05/2019 04:13:15.
For the particular location of the damage in the above example, the damage has Y coordinates close to zero, the Y
histogram shows many peaks with values around 800 for the correct location of the damage Y coordinates, yet choosing the
tallest peaks above 1000 would cause erroneous decision regarding the Y coordinates of the damage slot. The same applies
to the X coordinates, the tallest histogram peaks do not correspond to the correct location of the damage slot.

Using multiple intersecting circles or ellipses to detect targets, not only pin-points the location of damage over the metal
sheet, but it also allows measuring span of for instance a straight scratch, which is the objective of the research article.

To measure the 'width' of the slot one could process the intersection of NS ellipses, one ellipse from each sensor, and do it
for each detected damage point. Then measure tip-to-tip distance.

The ellipses defined with parameters stored in structure ell

ell ell =
1×10 struct array with fields:
centroid
c_dist
phi
d
a
b
scr2

The following part of the script 2nd cell, plots the actual ellipse points:

figure(4);
plot([x_range(1) x_range(end) x_range(end) x_range(1) x_range(1)],...
[y_range(1) y_range(1) y_range(end) y_range(end) y_range(1)],...
'LineWidth',2,...
'Color','b')

ax1.XTick=[x_range(1):10*x_res:x_range(end)]
ax1.YTick=[y_range(1):10*x_res:y_range(end)]
grid on

hold all
for k=1:1:NS
% figure(nk);
% title(['angle range sensor ' num2str(nk)])
plot(ell(k).centroid(1)+(ell(k).a)'.*cosd(ang2).*cosd(180/(2*pi)*ell(k).phi)-(ell(k).b)'.*sind(ang2).*sind(180/(2*pi)*ell(k).phi),...
ell(k).centroid(2)+(ell(k).a)'.*cosd(ang2).*sind(180/(2*pi)*ell(k).phi)+(ell(k).b)'.*sind(ang2).*cosd(180/(2*pi)*ell(k).phi),'+')

end

plot([x_d-Nd*x_res x_d+Nd*x_res],[y_d-Nd*x_res y_d+Nd*x_res],...


'LineWidth',1,...
'Color','k')

scr3

_________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com https://jgb2012.wixsite.com/microwave-eng-matlab 6 / 12
MATLAB support QA001 29/05/2019 04:13:15.

Observe that despite there are


ellipse points with values
outside the rectangle, only
those values inside should be
considered.

In the above example, the


target is located on the right
hand side, inside the small red
rectangle, despite that visually
there's a yellow spot of some
overlapping ellipses, not all of
them, on the left hand side
that would have taller
histogram peak values, and
would 'shine' brighter in the
equivalent overlapping graphs
chosen by the research authors
to close point 3 of their
research.

fig7

Following, zoom on the


contents of the small red
rectangle. The damage to
detect and measure its span
is the straight black
segment in the following
figure:

There are really few ellipse


points that one can affirm to
be right on the damage
segment.

fig8

_________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com https://jgb2012.wixsite.com/microwave-eng-matlab 7 / 12
MATLAB support QA001 29/05/2019 04:13:15.

Alternatively one
may consider
choosing the shape
of the detected
damage as the
arrangement of
ellipse points that
show highest
alignment, but only
within the narrow
rectangle that must
contain NS*Nd
ellipse points, and at
the same time there
have to be inside
such rectangle at
least Nd points from
each sensor.

That would likely


estimate the target
with the red
segment.

fig9

An alignment accuracy index could then be defined similar to Error Vector Measurement (EVM) that test instruments and
mobile phones carry out on wireless signals constellations to tell how noisy are received symbols.

Firstly zoom on the narrow are where all ellipses coincide, and then measure distance and angles between adjacent points,
to choose an estimate shape of the slot to detect.

Another example with scattered sensors:

fig10

_________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com https://jgb2012.wixsite.com/microwave-eng-matlab 8 / 12
MATLAB support QA001 29/05/2019 04:13:15.

There's high alignment around the yellow spot on the left hand side, but it's caused by only a few ellipses.

zoom on yellow spot zoom on actual damage area

fig11

On figure 10 that yellow spot not all ellipses are present, so such narrow area should be discarded and measure alignment
only where all sensors produce ellipse points, for all Nd target points present.

Accuracy understood as tightness of the red rectangle on the correct damage area, improves when

 sensors are closer to the damage


 sensors are grouped in tight formation
 using higher number of sensors
 using higher angular resolution

_________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com https://jgb2012.wixsite.com/microwave-eng-matlab 9 / 12
MATLAB support QA001 29/05/2019 04:13:15.

I have tried increasing angle accuracy 10 fold, 0.1° angle resolution d_ang_res=2*pi/3600

Now it's difficult to visually discern what points have best


alignment.

fig12

There's even a false high alignment really close to the actual target, the red spot right on the blue boundary rectangle.

Yet the higher density of points in the narrow rectangle where all sensors produce ellipse points should allow for a more
accurate estimation of the target, provided a correct definition of alignment, EVM like, has been previously written.

It's important to keep sensors in tight formation, or an excessive misalignment of the ellipses causes that there is no such
narrow rectangle where all sensors produce Nd points each.

Then such narrow rectangle spans excessively reducing the accuracy required to pin point the damage slot.

_________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com https://jgb2012.wixsite.com/microwave-eng-matlab 10 / 12
MATLAB support QA001 29/05/2019 04:13:15.

It's in my opinion important to underline this point, because an excessive scattering of sensors may cause such ellipses
misalignment that pushes the target completely out of the narrow area where all ellipses overlap, and thus the all ellipses
intersecting method for each point belonging to the target would lead to locations where the target is not located at all.

To understand this, see the following example; the small red rectangle is the narrow area where all ellipses intersect, where
the overlap graph would show a estimation of the slot span, yet the target is actually located away of that area, the target
area not even containing all ellipses, yet being the area that should be produced as result:

fig12

fig13

_________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com https://jgb2012.wixsite.com/microwave-eng-matlab 11 / 12
MATLAB support QA001 29/05/2019 04:13:15.

To simulate with different sensor locations while holding same damage points, either edit S directly, or store the current
location of the target, for instance with save S.mat S , and then replace line

S=.1*floor(10*[x_d-Nd*x_res:x_res:x_d+Nd*x_res;y_d-Nd*x_res:x_res:y_d+Nd*x_res])

with

load('S.mat')

and run again the 1st cell to be prompted where to relocate sensors to.

Further development of this script:

Include in structure ell the set of points of each ellipse.

Calculate each intersection point out of NS ellipses for each intersecting point, up to the Nd target points, this would allow
for the shape estimation of any arbitrary damage shape, not only straight slots. The function intersections.m would be
needed to obtain the actual intersecting points out of the available ellipse points.

The function intersections.m is available here:


https://uk.mathworks.com/matlabcentral/fileexchange/11837-fast-and-robust-curve-intersections

_________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com https://jgb2012.wixsite.com/microwave-eng-matlab 12 / 12

S-ar putea să vă placă și