Skip to content

Instantly share code, notes, and snippets.

@egglang
Created December 22, 2016 04:54
Show Gist options
  • Save egglang/93c2e95dc68c3d461d8c14980118a98e to your computer and use it in GitHub Desktop.
Save egglang/93c2e95dc68c3d461d8c14980118a98e to your computer and use it in GitHub Desktop.
MATLAB code for plotting ultrasonic test result
x = [ 0 0 0 0 0 0 0 9 9 9 9 9 9 9 9 9 9 9 9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 0 0 0 0 0 0 9 9 9 9 9 9 9 9 9 9 9 9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 -9 0 0 0 0 0 0 -8 -8 -8 -8 -8 -8 -4.5 -4.5 -4.5 -4.5 -4.5 -4.5 8.0 8.0 8.0 8.0 8.0 8.0 4.5 4.5 4.5 4.5 4.5 4.5 -0.2 -0.2 -0.2 -0.2 -0.2 -0.2 -0.2 -0.2 -0.2 -0.2 -0.2 -0.2 -0.2 -0.2 -0.2 -0.2 -0.2 -0.2 0.2 0.2 0.2 0.2 0.2 0.2 0.2 0.2 0.2 0.2 0.2 0.2 8.8 8.8 8.8 8.8 8.8 8.8 9.0 9.0 9.0 9.0 9.0 9.0 9.0 9.0 9.0 8.0 8.0 8.0 7.8 7.8 7.8 7.6 7.6 7.6 7.6 7.6 7.6 7.4 7.4 7.4 ]
y = [ 0 22 22 22 22 22 22 22 22 22 22 22 22 11 11 11 11 11 11 11 11 11 11 11 11 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 11 11 11 11 11 11 22 22 22 11 11 11 22 22 22 22 22 22 11 11 11 20 20 20 20 20 20 20 20 20 20 20 20 11 11 11 11 11 11 20 20 20 20 20 20 11 11 11 11 11 11 11 11 11 11 11 11 22 22 22 11.2 11.2 11.2 11 11 11 11 11 11 22 22 22 11.2 11.2 11.2 11 11 11 11 11 11 11.2 11.2 11.2 11.2 11.2 11.2 11.2 11.2 11.2 11 11 11 10.8 10.8 10.8 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 ]
result = [ 1 1 1 1 1 0 1 1 0 1 1 1 0 0 0 0 0 0 0 1 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 0 1 0 0 0 1 0 0 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 0 1 1 1 0 1 1 0 0 0 0 1 1 1 1 1 0 0 1 1 0 1 0 0 1 1 0 1 1 1 0 0 1 1 1 1 1 0 0 1 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 1 0 1 0 0 0 1 1 1 1 0 0 1 0 0 1 1 1 ]
who = [ 1 1 1 1 1 1 1 2 2 2 2 2 2 3 3 3 3 3 3 4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 2 2 2 5 5 5 5 5 5 4 4 4 4 4 4 3 3 3 3 3 3 1 1 1 1 1 1 2 2 2 2 2 2 3 3 3 3 3 3 1 1 1 1 1 1 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 1 1 1 3 3 3 3 3 3 1 1 1 1 1 1 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 2 2 2 5 5 5 3 3 3 4 4 4 1 1 1 2 2 2 5 5 5 4 4 4 3 3 3 ]
N = numel(x)
nx = randi(10,1,N) .* 0.05
ny = randi(10,1,N) .* 0.025
A = round(rand(1,N));
A(A==0) = -1
x2 = x + (nx .* A)
A = round(rand(1,N));
A(A==0) = -1
y2 = y + (ny .* A)
x2(1) = 0
y2(1) = 0
result(1) = 2
gscatter(x2,y2,result,'rbk','xo*')
xlabel('Width (m)');
ylabel('Depth (m)');
legend('Failure', 'Success', 'Speaker position')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment