14 lines
332 B
Matlab
Executable File
14 lines
332 B
Matlab
Executable File
function [indices, z] = get_sparse_vector(N, Amp)
|
|
global K extend_target;
|
|
z = zeros(N, 1);
|
|
if extend_target
|
|
target_start_idx = fix(0.4 * N);
|
|
target_size = K;
|
|
indices = target_start_idx: target_start_idx + target_size;
|
|
else
|
|
indices = randperm(N, K);
|
|
end
|
|
z(indices) = Amp;
|
|
end
|
|
|