function [ind] = vec2ind_inclrest(vec)
% Like vec2ind, but deals differently with 0s % % [IND] = VEC2IND_INCLREST(VEC) % % See the builtin VEC2IND function for more information. This takes % in a matrix, and tells you where the 1 is for every column. % % Useful for figuring out which condition is active in your binary regressors
[isbool isrest isoveractive] = check_1ofn_regressors(vec);
if ~isbool error(‘Vec needs to be boolean’); end
if isoveractive error(‘Can”t have more than one active item in each column’); end
[nrows ncols] = size(vec);
ind = zeros(1,ncols); for i = 1:nrows ind(find(vec(i,:))) = i; end
Home - Blog - Startups - Software - Research - Writing
Email me - updated 31 Dec 2012