-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtryvalg2.m
30 lines (26 loc) · 1.01 KB
/
tryvalg2.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
function v=tryvalg2(phi)
% Version June 2012.
% Gives performance of constrained (phase only) case
% Used with fitness.m when using fminsearch
% outputs either noise-to-signal power ratio or sum of squared errors
% depending on PerfType
%phi(k) is the phase of the phase shifter for k-th sensor.
%global statement should match that in other functions for this application
global A DESIRED WaveNumber LookAngles CheckAngle OptType PerfType
wH=exp(j*phi);
response=wH*A;
if strcmp(PerfType,'MSE')
v=(DESIRED-response)*(DESIRED-response)'; %sum of squared errors
elseif strcmp(PerfType,'NSR')
sigpow=sum(abs(response(DESIRED>0)).^2);
noisepow=sum(abs(response(DESIRED==0)).^2);
v= noisepow/sigpow;
elseif strcmp(PerfType,'MinMax')
sigpow=sum(abs(response(DESIRED>0)).^2);
noisepow=sum(abs(response(DESIRED==0)).^2);
v=noisepow/sigpow;
elseif strcmp(PerfType,'SD')
v=sqrt(((DESIRED-response)*(DESIRED-response)')/(length(DESIRED)-1));
else
error('Bad PerfType value. tryvalg.m')
end