-
Notifications
You must be signed in to change notification settings - Fork 0
/
main2D.m
70 lines (60 loc) · 1.39 KB
/
main2D.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
%close all
N=50;
fs=50;
f=1;
S = [];
% for k=0.0001:0.0001:0.001
N = 3;
% alpha1 = -k + 2*k*rand(1,N);
% alpha2 = -k + 2*k*rand(1,N);
ts=1/fs;
t = ts*(0:N-1);
% template= [sin(2*pi*f*t); t];
% input= [alpha1 + cos(2*pi*f*t); t + alpha2];
template = [0, 1, 0; 0, 0, 1];
input = [0, 1, 0; 0, 0, -1];
%figure
%hold on
%plot(t,template(1,:), '*g')
%plot(t,input(1,:), '*r')
shape_template = zeros(1,N-2);
shape_input = zeros(1,N-2);
Sum = 0;
for j=2:N-1
a = template(:,j)-template(:,j-1);
b = template(:,j+1)-template(:,j);
a_c = a(1) + a(2)*i;
b_c = b(1) + b(2)*i;
shape_template(1,j-1) = a_c/b_c;
u = input(:,j)-input(:,j-1);
v = input(:,j+1)-input(:,j);
u_c = u(1) + u(2)*i;
v_c = v(1) + v(2)*i;
shape_input(1,j-1) = u_c/v_c;
Sum = Sum + LSD(a,b,u,v);
end
Sum
input = fliplr(input);
Sum = 0;
for j=2:N-1
a = template(:,j)-template(:,j-1);
b = template(:,j+1)-template(:,j);
a_c = a(1) + a(2)*i;
b_c = b(1) + b(2)*i;
shape_template(1,j-1) = a_c/b_c;
u = input(:,j)-input(:,j-1);
v = input(:,j+1)-input(:,j);
u_c = u(1) + u(2)*i;
v_c = v(1) + v(2)*i;
shape_input(1,j-1) = u_c/v_c;
Sum = Sum + LSD(a,b,u,v);
end
Sum
%figure
%hold on
%plot(shape_input, '*r');
%plot(shape_template, '*g');
S = [S, Sum];
% end
figure
plot(S, '*b')