-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrandMixingMat.m
More file actions
34 lines (32 loc) · 823 Bytes
/
randMixingMat.m
File metadata and controls
34 lines (32 loc) · 823 Bytes
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
function [A PI] = randMixingMat(n)
%------------------------------------------------------------------------
%
% randMixingMat.m:
% Creates an an random normal arbitrary mixing matrix.
%
% Inputs:
% n: The size of the mixing matrix
%
% Outputs:
% PI: The permutation matrix
% A: The scrambled diagonal mixing matrix
%
%------------------------------------------------------------------------
% Create random normal vector
a = randn(n, 1);
% Diagonalize
aa = diag(a);
% Create arbitrary permutation matrix
PI = permMat(n);
% Scramble diagonal matrix
A = PI*aa;
% Introduce random noise
% Find minimum magnitude of elements and halve it to avoid exceeding
% existing elements in all cases.
alpha = 0.45;
b = alpha*nonzeros(A');
N = b*ones(1,n).*rand(n);
nega = 2.*binornd(1, 0.5, n) - 1;
N = nega.*N;
A = A + N;
end