from
simbus
by Sanjai Singh The DataBus Blockset provides a method for manipulating signals from a vector in SIMULINK.
addtobus(busname, signals)
function [Indices,vecSize] = addtobus(busname, signals)
%ADDTOBUS Returns Indices and vector size to create a D matrix using busdmat.
%Copyright (c) 1995 by The MathWorks, Inc.
%$Revision: 1.1 $ $Date: 1997/02/11 20:49:13 $
% Get strings and sizes from bus file
[strings,sizes] = busread(busname);
% Find indices of string names passed in
[SelectedIndices,vecSize] = parsebus(busname, signals, strings, sizes);
% Calculate the data lengths
SigLength = length(SelectedIndices);
BusLength = sum(sizes);
NumSignals = length(sizes);
% Create a vector to index the current bus
Indices = 1:BusLength;
% Replace the indices of selected vector with the Indices at the end of the bus
Indices(SelectedIndices) = (BusLength+1):(BusLength+SigLength);
% Calculate final vector size
vecSize = BusLength+SigLength;