This is my code:
%% Variable
a_cor_width = 0.2e-9; % Auto-correlation width
N_def = 200/(a_cor_width*10^9); % 200e-9 means bandwidth, As reference
lambda_def = linspace(1400e-9, 1600e-9, N_def);
%% Random transmission matrix generation
M = 20; % Sampling channel >> Should be matrix
T_def = rand(M,N_def);
N = 5000; % Spectral pixel >> Should be matrix
lambda = linspace(1400e-9, 1600e-9, N);
T = spline(lambda_def, T_def, lambda);
for i=1:M
for j=1:N
if T(i,j) > 1
T(i,j) = 1;
elseif T(i,j) < 0
T(i,j) = 0;
end
end
end
% plot(lambda, T(1,:), lambda, T(2,:))
%% Reconstruction using cvx
delta_lambda = 200e-9/N;
ref_wavelength = lambda(3751); % 3751은 대충 1550
second_wavelength = lambda(3751+2);
input_spectrum = zeros(N, 1);
for i=1:N
if i==3751 | i==3751+2
input_spectrum(i) = 1;
else
input_spectrum(i) = 0;
end
end
output_I = T * input_spectrum;
cvx_begin
variable x(N, 1)
minimize( abs(output_I - T*x) )
cvx_end
In this case, it gives the error, “Your objective function is not a scalar”. What can I do to resolve this problem?