-
Notifications
You must be signed in to change notification settings - Fork 0
/
matlabscript.m
69 lines (60 loc) · 1.24 KB
/
matlabscript.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
function [R] = weightDesign()
%---------
% READ INPUT FILES
%---------
fileID = fopen('input_param.txt','r');
formatSpec = '%f';
A = fscanf(fileID, formatSpec);
fclose(fileID);
fileID2 = fopen('curr_angle.txt','r');
B = fscanf(fileID2, formatSpec);
fclose(fileID2);
%---------
% STORE VALUES FROM INPUT PARAMETERS
%---------
Pt = A(1);
angle_j = B;
Nt = A(3);
start_a = A(4);
end_a = A(5);
%---------
% INITIAL CALCULATIONS
%---------
deg2rad = pi/180;
vTheta_rad = angle_j*deg2rad;
vTheta_rad;
phi = sin(vTheta_rad);
for idx=1:length(B)
TxArray(:,idx) = exp(1i*pi*phi(idx)*[0:1:(Nt-1)]);
end
%---------
% CVX CALCULATIONS
%---------
cvx_begin sdp quiet
variable R(Nt,Nt) hermitian toeplitz
variable eta
maximize eta
R >= 0;
eta >= 0;
trace(R)<=Pt;
for idx=1:length(B)
real(TxArray(:,idx)'*R*TxArray(:,idx)) >= eta;
end
cvx_end
%---------
% SAVE MATLAB STATUS
%---------
mstatus = fopen('matlab_status.txt', 'w');
fprintf(mstatus, cvx_status);
fclose(mstatus);
%---------
% FINAL CALCULATIONS
%---------
[U,S,V] = svd(R);
C = U*S^(1/2)*V';
%---------
% SAVE OUTPUT FILES
%---------
save('C');
FileData = load('C.mat');
csvwrite('C.csv', FileData.C);