www.gusucode.com > trading工具箱matlab源码程序 > trading/trading/fix2struct.m
function fixStruct = fix2struct(sFIX) %STRUCT2FIX FIX string to MATLAB structure. % FIXSTRUCT = FIX2STRUCT(SFIX) converts the FIX message string, SFIX, to a % MATLAB structure, FIXSTRUCT. % % See also struct2fix. % Copyright 2016 The MathWorks, Inc. % Load fix tags persistent fixtags %#ok if isempty(fixtags) load fixtags5_0_2 end % Parse FIX string to structure if ischar(sFIX) sFIX = cellstr(sFIX); end % Replace SOH characters with = sohChar = 1; % Loop through messages numMessages = length(sFIX); fixTagsValues = []; for i = 1:numMessages % Replace SOH with = iSOH = (sFIX{i} == sohChar); sFIX{i}(iSOH) = '='; % Scan string into cell array fixTagsValues = [fixTagsValues textscan(sFIX{i},'%f%s','Delimiter','=')]; %#ok fixTagStrings = fixtags(fixTagsValues{1},2); end % Move tag values to cell array and create structure of arrays structValues = [fixTagsValues{2:2:end}]'; for i = 1:length(fixTagStrings) if exist('fixStruct','var') && isfield(fixStruct,fixTagStrings{i}) fixStruct.(fixTagStrings{i})(:,end+1) = structValues(:,i); else fixStruct.(fixTagStrings{i}) = structValues(:,i); end end