function [Indices,vecSize] = parsebus(busname, names, strings, sizes)
% PARSEBUS 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:51:28 $
% The list of strings and sizes of the bus
if (nargin >= 4)
Strings = strings;
Sizes = sizes;
else
[Strings, Sizes] = busread(busname);
end
NumSignals = length(Sizes);
Indices = [];
cumSizes = cumsum(Sizes);
remain = names;
while ~isempty(remain)
[name, remain] = strtok(remain, '|');
found = 0;
for i = 1:NumSignals
if strcmp(name, deblank(Strings(i,:)))
found = 1;
if i == 1
Indices = [Indices, 1:Sizes(i)];
else
Indices = [Indices, (cumSizes(i-1)+1):cumSizes(i)];
end
break
end
end
if ~found
str1=['String "' name '" not found in bus definition.'];
str2='Available outputs are:';
str3=Strings;
VersionNum = str2num(strtok(version,'.'));
if (VersionNum < 5)
[sys,cb]=get_param;
else
sys=get_param(0,'CurrentSystem');
cb =get_param(sys,'CurrentBlock');
end
errstr=str2mat(str1,str2,' ',str3);
errordlg(errstr,[sys '/' cb ' Error']);
error(str1)
end
end
vecSize = cumSizes(NumSignals);