from
simbus
by Sanjai Singh The DataBus Blockset provides a method for manipulating signals from a vector in SIMULINK.
busdmat(Indices,vecSize)
function D = busdmat(Indices,vecSize)
% BUSDMAT Generates a D matrix given a set of indices and a vector size
%Copyright (c) 1996 by The MathWorks, Inc.
%$Revision: 1.1 $ $Date: 1997/02/11 20:49:54 $
IndicesLength = length(Indices);
dIndex = Indices * IndicesLength - IndicesLength + (1:IndicesLength);
D = zeros(IndicesLength, vecSize);
D(dIndex) = ones(IndicesLength, 1);