-
Notifications
You must be signed in to change notification settings - Fork 10
/
main_1D.m
370 lines (355 loc) · 14.6 KB
/
main_1D.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
clc;
clear all;
clear global;
close all;
oned_testmode = 'compara_esprit';
switch oned_testmode
case 'auto'
[beam1,en1] = lms();
[beam2,en2] = nlms();
[beam3,en3] = rls();
% plotting
figure('Color','white');
angle=-90:180/200:(90-180/200);
% subplot(2,1,1);
plot(angle,beam1);hold on;
plot(angle,beam2);hold on;
plot(angle,beam3);hold on;
legend('LMS','NLMS','RLS');
grid on;
xlabel('方向角/degree');
ylabel('幅度响应/dB');
title('方向图');
figure('Color','white');
semilogy(en1);hold on;
semilogy(en2);hold on;
semilogy(en3);hold on;
legend('LMS','NLMS','RLS');
grid on;
xlabel('迭代次数');
ylabel('MSE');
title('MSE');
case 'compara_esprit'
theta0 = [-60 -45 -30 -15 0 20 40];
[rmse1]=conjugate_esprit(theta0,8);
[rmse2]=espirit(theta0,8);
figure('Color','white');
plot(-10:1:9,rmse1,'g*-',-10:1:9,rmse2,'ro-');
grid on;
xlabel('SNR/dB');
ylabel('RMSE/degree');
title('共轭TLS-ESPRIT与TLS-ESPRIT算法在不同信噪比下的均方根误差');
legend('conjugate esprit','esprit');
case 'conjugate_esprit'
theta0 = [-60 -45 -30 -15 0 20 40 60];
[rmse]=conjugate_esprit(theta0,8);
figure('Color','white');
plot(rmse,'*-');
grid on;
xlabel('SNR/dB');
ylabel('RMSE/degree');
title('共轭ESPRIT算法在不同信噪比下的均方根误差');
case 'espirit'
theta0 = [-60 -45 -30 0 20 40 60];
[rmse]=espirit(theta0,8);
figure('Color','white');
plot(rmse,'*-');
grid on;
xlabel('SNR/dB');
ylabel('RMSE/degree');
title('ESPRIT算法在不同信噪比下的均方根误差');
case 'music_and_espirit'
theta0 = [10 30 60];
theta=linspace(-90,90,361);
[abs_p,peak_ang,snr1,rmse1] = music(theta0,8,0.5,'not_multi');
[rmse2] = espirit(theta0,8);
figure('Color','white');
plot(snr1,rmse1,'r*-',snr1,rmse2,'b*-');
title('MUSIC算法与ESPRIT算法不同信噪比下测角均方误差');
xlabel('SNR/dB');ylabel('RMSE/degree');
legend('MUSIC','ESPIRIT');
case 'rootmusic_and_espirit'
theta0 = [0 30 60];
[snr1,rmse1] = root_music(theta0,8,0.5);
[rmse2] = espirit(theta0,8);
figure('Color','white');
plot(snr1,rmse1,'ro-',snr1,rmse2,'g*-');
grid on;
title('ROOT-MUSIC算法与ESPRIT算法不同信噪比下测角均方误差');
xlabel('SNR/dB');ylabel('RMSE/degree');
legend('ROOT-MUSIC','ESPIRIT');
case 'nor_and_ss_music'
theta0 = [10 30 60];
theta=linspace(-90,90,361);
[abs_p1,peak_ang1] = music(theta0,8,0.5,'multi_path');
abs_p2 = ss_music(theta0,8,0.5,'multi_path');
figure('Color','white');
h=plot(theta,abs_p1,'g',theta,abs_p2,'r');
set(h,'Linewidth',2)
xlabel('angle (degree)')
ylabel('abs of P (dB)')
axis([-90 90 -60 0]);
set(gca, 'XTick',[-90:30:90]);
grid on;
legend('MUSIC','空间平滑MUSIC');
title({['MUSIC算法和空间平滑MUSIC算法在多径传输下的性能比较']...
['来波方向为:' num2str(theta0) '信源相同的方向为:' num2str(theta0(1:2))]});
case 'root_music'
theta0 = [45 30 60];
[snr,rmse] = root_music(theta0,8,0.5);
figure('Color','white');
plot(snr,rmse,'ro-');
title('ROOT-MUSIC算法不同信噪比下测角均方误差');
xlabel('SNR/dB');ylabel('RMSE/degree');
case 'ss_music'
theta=linspace(-90,90,361);
theta0 = [0 30 60];
abs_p = ss_music(theta0,8,0.5,'multi_path');
figure('Color','white');
h=plot(theta,abs_p);
set(h,'Linewidth',2);
xlabel('angle (degree)');
ylabel('abs of P (dB)');
axis([-90 90 -60 0]);
set(gca, 'XTick',[-90:30:90], 'YTick',[-60:10:0]);
grid on;
title('平滑MUSIC功率谱');
case 'normal_and_music'
theta0 = [ -50 -30 -10 10 30 50 70 ];
[abs_f1,abs_p1] = normal(theta0,8,0.5);
[abs_p2,peak_ang,snr,rmse] = music(theta0,8,0.5,'not_multi');
[abs_f3,abs_p3] = capon(theta0,8,0.5);
theta=linspace(-90,90,200);
figure('Color','white');
plot(theta,abs_p1);hold on;
plot(theta,abs_p2);hold on;
plot(theta,abs_p3);hold on;
xlabel('angle (degree)');
ylabel('abs of P /dB');
grid on;
title( ['功率谱,来波方向为:' num2str(theta0)]);
legend('延迟相加法','music','Capon');
case 'music'
theta0 = [10 20 30 40 50 60 70 ];
[abs_p,peak_ang,snr,rmse] = music(theta0,8,0.5,'not_multi');
theta=linspace(-90,90,200);
figure('Color','white');
h=plot(theta,abs_p);
% hold on;
% plot(peak_ang,abs_p(peak_ang*2+181),'ro');
% set(h,'Linewidth',2);
xlabel('angle (degree)');
ylabel('abs of P /dB');
% axis([-90 90 -60 0]);
% set(gca, 'XTick',[-90:30:90]);
grid on;
title( ['MUSIC功率谱,来波方向为:' num2str(theta0)]);
% title( {['MUSIC功率谱,来波方向为:' num2str(theta0)]...
% ['谱峰搜索结果为:' num2str(peak_ang)]});
% figure('Color','white');
% plot(snr,rmse,'ro-');
% title('MUSIC算法不同信噪比下测角均方误差');
% xlabel('SNR');ylabel('RMSE');
case 'normal_theta_and_direction'
%% 普通波束形成的波束宽度随方向的变化
theta=linspace(-90,90,200);
d_lamda = 1/2;
theta0 = [0 40 60 80];
[abs_f1,abs_p1] = normal(theta0(1),8,d_lamda);
[abs_f2,abs_p2] = normal(theta0(2),8,d_lamda);
[abs_f3,abs_p3] = normal(theta0(3),8,d_lamda);
[abs_f4,abs_p4] = normal(theta0(4),8,d_lamda);
figure('Color','white');
plot(theta,abs_f1);hold on;
plot(theta,abs_f2);hold on;
plot(theta,abs_f3);hold on;
plot(theta,abs_f3);hold on;
grid on;
title('8阵元线阵方向图' );
xlabel('theta/degree');ylabel('abs of F');
legend('0度','40度','60度','80度');
% figure('Color','white');
% subplot(411);
% plot(theta,abs_f1,'r');grid on;
% title(['16阵元线阵方向图,指向方向为',num2str(theta0(1)) '度']);
% xlabel('theta/degree');ylabel('abs of F');
% subplot(412);
% plot(theta,abs_f2,'r');grid on;
% title(['16阵元线阵方向图,指向方向为',num2str(theta0(2)) '度']);
% xlabel('theta/degree');ylabel('abs of F');
% subplot(413);
% plot(theta,abs_f3,'r');grid on;
% title(['16阵元线阵方向图,指向方向为',num2str(theta0(3)) '度']);
% xlabel('theta/degree');ylabel('abs of F');
% subplot(414);
% plot(theta,abs_f4,'r');grid on;
% title(['16阵元线阵方向图,指向方向为',num2str(theta0(4)) '度']);
% xlabel('theta/degree');ylabel('abs of ');
case 'normal_resolution'
%% 普通波束形成的分辨力问题
theta=linspace(-90,90,200);
d_lamda = 1/2;
theta1 = [0 30 60];
[abs_f1,abs_p1] = normal(theta1,8,d_lamda);
theta2 = [0 10 60];
[abs_f2,abs_p2] = normal(theta2,8,d_lamda);
theta3 = [0 50 60];
[abs_f3,abs_p3] = normal(theta3,8,d_lamda);
figure('Color','white');
subplot(311);
plot(theta,abs_p1,'r');grid on;
title(['8阵元线阵功率谱,来波方向为',num2str(theta1) '度']);
xlabel('theta/degree');ylabel('abs of P');
subplot(312);
plot(theta,abs_p2,'r');grid on;
title(['8阵元线阵功率谱,来波方向为',num2str(theta2) '度']);
xlabel('theta/degree');ylabel('abs of P');
subplot(313);
plot(theta,abs_p3,'r');grid on;
title(['8阵元线阵功率谱,来波方向为',num2str(theta3) '度']);
xlabel('theta/degree');ylabel('abs of P');
case 'theta_and_array_numb'
%% 测试阵元数目对波束宽度的影响
theta0 = 0;
d_lamda = 1/2;
[abs_f1,abs_p1] = normal(theta0,8,d_lamda);
[abs_f2,abs_p2] = normal(theta0,16,d_lamda);
[abs_f3,abs_p3] = normal(theta0,32,d_lamda);
theta=linspace(-90,90,200);
figure('Color','white');
% subplot(211);
plot(theta,abs_f1,'g');hold on;
plot(theta,abs_f2,'r');hold on;
plot(theta,abs_f3,'b');hold on;
grid on;
xlabel('theta/degree')
ylabel('abs of F')
title([ '均匀线阵方向图','指向' num2str(theta0) '度' ]);
legend('8阵元','16阵元','32阵元');
% subplot(212);
% plot(theta,abs_p1,'g');hold on;
% plot(theta,abs_p2,'r');hold on
% plot(theta,abs_p3,'b');hold on;
% grid on;
% xlabel('theta/degree')
% ylabel('abs of P')
% title([ '均匀线阵功率谱','来波方向为' num2str(theta0) '度']);
% legend('8阵元','16阵元','32阵元');
case 'normal'
%% 测试普通波束形成
theta0 = [-10,10];
d_lamda = 1/2;
[abs_f,abs_p] = normal(theta0,8,d_lamda/2);
theta=linspace(-90,90,200);
figure('Color','white');
plot(theta,abs_f);hold on;
grid on;
xlabel('theta/degree')
ylabel('abs of F')
title([ '普通波束形成方向图' '波束指向' num2str(theta0) '度' ]);
figure('Color','white');
plot(theta,abs_p);hold on;
grid on;
xlabel('theta/degree')
ylabel('abs of P')
title([ '延迟相加法功率谱' ]);
case 'theta_and_array_span'
%% 测试阵元间距对波束宽度的影响
theta0 = 0;
d_lamda = 1/2;
[abs_f1,abs_p1] = normal(theta0,8,d_lamda/2);
[abs_f2,abs_p2] = normal(theta0,8,d_lamda);
[abs_f3,abs_p3] = normal(theta0,8,d_lamda/2*3);
[abs_f4,abs_p4] = normal(theta0,8,d_lamda/2*5);
theta=linspace(-90,90,200);
figure('Color','white');
plot(theta,abs_f1);hold on;
plot(theta,abs_f2);hold on;
plot(theta,abs_f3);hold on;
plot(theta,abs_f4);hold on;
grid on;
xlabel('theta/degree')
ylabel('abs of F')
legend('0.25lamda','0.5lamda','0.75lamda','1.25lamda');
title([ '阵元间距与波长的比例对方向图的影响' ' 波束指向' num2str(theta0) '度' ]);
% theta0 = 0;
% d_lamda = 1/2;
% [abs_f1,abs_p1] = normal(theta0,8,d_lamda/2);
% [abs_f2,abs_p2] = normal(theta0,8,d_lamda);
% [abs_f3,abs_p3] = normal(theta0,8,d_lamda/2*3);
% [abs_f4,abs_p4] = normal(theta0,8,d_lamda/2*5);
% theta=linspace(-90,90,200);
% figure('Color','white');
% subplot(411);
% plot(theta,abs_f1,'g');
% grid on;
% xlabel('theta/degree')
% ylabel('abs of F')
% title([ '阵元间距' num2str(d_lamda/2) 'lamda均匀线阵方向图','指向' num2str(theta0) '度' ]);
% subplot(412);
% plot(theta,abs_f2,'r');
% grid on;
% xlabel('theta/degree')
% ylabel('abs of F')
% title([ '阵元间距' num2str(d_lamda) 'lamda均匀线阵方向图','指向' num2str(theta0) '度' ]);
% subplot(413);
% plot(theta,abs_f3,'b');
% grid on;
% xlabel('theta/degree')
% ylabel('abs of F')
% title([ '阵元间距' num2str(d_lamda/2*3) 'lamda均匀线阵方向图','指向' num2str(theta0) '度' ]);
% subplot(414);
% plot(theta,abs_f4,'k');
% grid on;
% xlabel('theta/degree')
% ylabel('abs of F')
% title([ '阵元间距' num2str(d_lamda*2*1.5) 'lamda均匀线阵方向图','指向' num2str(theta0) '度' ]);
case 'normal_and_capon'
%% 对比一维普通波束形成与capon
theta0 = [30,60];
d_lamda = 1/2;
[abs_f1,abs_p1] = normal(theta0,8,d_lamda);
[abs_f2,abs_p2] = capon(theta0,8,d_lamda);
theta=linspace(-90,90,200);
figure('Color','white');
plot(theta,abs_p1);hold on;
plot(theta,abs_p2);hold on;
grid on;
xlabel('theta/degree');
ylabel('abs of P');
title([ '8阵元均匀线阵功率谱','来波方向为' num2str(theta0) '度']);
legend('normal','capon');
theta0 = [30,40];
d_lamda = 1/2;
[abs_f1,abs_p1] = normal(theta0,8,d_lamda);
[abs_f2,abs_p2] = capon(theta0,16,d_lamda);
figure('Color','white');
plot(theta,abs_p1);hold on;
plot(theta,abs_p2);hold on;
grid on;
xlabel('theta/degree')
ylabel('abs of P')
title([ '8阵元均匀线阵功率谱','来波方向为' num2str(theta0) '度']);
legend('normal','capon');
case 'capon'
%% 对比一维普通波束形成与capon
theta0 = [0 35];
d_lamda = 1/2;
[abs_f,abs_p] = capon(theta0,16,d_lamda);
theta=linspace(-90,90,200);
figure('Color','white');
plot(theta,abs_f,'r');hold on;
plot(theta0(1),-30:0,'.',theta0(2),-30:0,'.');
grid on;
xlabel('theta/degree');
ylabel('abs of P');
title([ 'Capon均匀线阵方向图(普通波束形成)','来波方向为' num2str(theta0) '度']);
figure('Color','white');
plot(theta,abs_p,'r');
grid on;
xlabel('theta/degree');
ylabel('abs of P');
title([ 'Capon均匀线阵功率谱(普通波束形成)','来波方向为' num2str(theta0) '度']);
otherwise
disp('Please input mode!');
end