MATLAB: Please how can I unstack a column of negative and positive values into 2 columns of positive and negative values respectively

unstackwilcoxon

sr=[-34;45;28;-10;-9]. s=sign(sr). I want to obtain sr1=[-34;-10;-9] and sr2=[45;28]

Best Answer

p=sr(sr>0); % positive only
n=sr(sr<0); % negative only, you'll have to decide where zero goes if it exists...
or,
ix=sr>0; % logical vector
p=sr(ix);
n=sr(~ix); % eliminate the test once at expense of temporary variable