-
Notifications
You must be signed in to change notification settings - Fork 8
/
generateData2.m~
128 lines (100 loc) · 3.67 KB
/
generateData2.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
function [allData, rawData, Label, sig] = generateData2(sig,target)
% revise for stack trajectry
% =================== Sig Block ============
% IN: Case, sig
% Out: X, Y
if strcmp(sig.geometry ,'ULA')
sig.d = 0.40;
sig.newLength = sig.M*(2*sig.M+1); % ToDo related to sig.M
elseif strcmp(sig.geometry ,'UCA')
sig.d = 0.40;
sig.newLength = sig.M*(2*sig.M+1); % ToDo related to sig.M
sig.phi = ( [360-57.4 360-69.1 13.3 106.3 360-170.8])./180*pi; % ToDo related to sig.M
elseif strcmp(sig.geometry ,'VectorSensor')
sig.phi = ( [360-57.4 360-69.1 13.3 106.3 360-170.8])./180*pi;
sig.gamma = [0 1/2 3/4 1/4 1/4]*pi;
sig.ita = [0 0 0 1/2 1/2]*pi;
sig.dt = 0.10;
sig.deltaT = 5 * sig.dt;
sig.newLength = 78; % 12*13/2
end
% ------ data setting --------
Sizefull = prod(sig.setN);
allData = zeros(Sizefull,sig.newLength);
rawData = zeros(Sizefull,sig.M,sig.N);
% ------- iterator of data -----
if sig.isRand
if strcmp(target.Para,'theta')
theta1Rnd = rand(1,180) *pi;
theta2Rnd = rand(1,180) *pi;
elseif strcmp(target.Para,'phi')
phi1Rnd = rand(1,180)*pi;
phi2Rnd = rand(1,180) *pi;
end
% theta2Rnd = theta1Rnd+ 1*pi/180; % overlap, so as mess num of source
else
theta1Rnd = [0:1:179]/180*pi;
theta2Rnd = [0:1:179]/180*pi;
% ====== follow trajectory ============
theta1Rnd = [0:1:179]/180*pi; % slow
end
% =================== synthesis data ============
tic;
i = 0;
for theta1Ind = 1:1:sig.setN(1)
for theta2Ind = 1:1:sig.setN(2)
i = i + 1;
% -- rewrite --
if strcmp(target.Para,'theta')
sig.theta(1) = theta1Rnd(theta1Ind);
sig.theta(2) = theta1Rnd(theta2Ind);
elseif strcmp(target.Para,'phi')
sig.phi(1) = phi1Rnd(theta1Ind);
sig.phi(2) = phi2Rnd(theta2Ind);
end
% sig.theta(1) = theta1Ind;
% sig.theta(2) = theta2Ind;
% ------- generate data -----
if strcmp(sig.geometry ,'ULA') ||strcmp(sig.geometry ,'UCA')
x = Sig(sig);
elseif strcmp(sig.geometry ,'VectorSensor')
x = VectorSensorSig(sig.theta,sig.phi,sig.gamma,sig.ita, sig.P, sig.f_c,...
sig.phi_c, sig.SNRdB, sig.N, sig.dt,sig.K,sig.type);
end
% ------- compress data -----
S = myCompress(x);
allData(i,:) = S;
rawData(i,:,:) = x; % for MUSIC
Label(i).K = sig.K;
Label(i).theta = sig.theta;
Label(i).f_c = sig.f_c;
Label(i).a = sig.P;
Label(i).N = sig.N;
Label(i).SNRdB = sig.SNRdB;
if strcmp(sig.geometry,'VectorSensor')
Label(i).phi = sig.phi;
Label(i).gamma = sig.gamma;
Label(i).ita = sig.ita;
Label(i).dt = sig.dt;
Label(i).deltaT = sig.deltaT;
end
if mod(i,1000) == 0
processMsg = sprintf('data generating %.2f %%', i*100.0/Sizefull);
disp(processMsg);
toc;
end
end
end
toc;
% tagTargetLabel = strcat(sig.caseID,'TargetLabel.mat');
% tagSampTarget = strcat('samp',sig.caseID,'Target.mat');
% tagSampInput = strcat('samp',sig.caseID,'Input.mat');
for i = 1:3
permID = randperm(Sizefull);
allData = allData(permID,:);
Label = Label(permID);
end
save( strcat('./Data/',sig.caseID,'Data.mat'), 'allData');
save( strcat('./Data/',sig.caseID,'RawData.mat'), 'rawData');
save( strcat('./Data/',sig.caseID,'Label.mat'), 'Label');
end