function [out,w,wi,rc] = instamix( in, b) % Return an arbitrarily conditioned mix and mixing matrix % % Usage: % [out,w,wi,rc] = instamix( in, b) % % Inputs: % in: the input sources, one in each row % b: an indication of the mixing matrix condition (0 = singular matrix) % % Outputs: % out: the resulting mix % w: the mixing matrix % wi: the inverse of the mixing matrix % rc: the reciprocal condition number of the mixing matrix % % If only one output is requested, w is returned % Default condition if nargin == 1 b = .5; end % Get the matrix [r,c] = size( in); w = ones( r, r); w = w + diag( r * b * ones( r, 1)); % Decide what to send out if nargout < 2 out = w; else out = w * in; end % Provide inverse of mixing matrix if asked to if nargout > 2 wi = inv( w); end % Ditto for reciprocal condition number if nargout == 4 rc = rcond( w); end