Code covered by the BSD License  

Highlights from
Automated Failure Boundary Mapping

image thumbnail

Automated Failure Boundary Mapping

by

 

18 Aug 2009 (Updated )

Demo files from July 21, 2009 webinar

updateModelParams(ds)
function model = updateModelParams(ds)

%   Copyright 2009 The MathWorks, Inc.

% Pull out variables for Simulink to update
idx = ismember(ds.Properties.UserData, 'slParam');
Units = ds.Properties.Units(idx);

% Update Simulink Model
for i = 1:length(Units)
    
    % Pull out model name
    [tok, mat] = regexp(Units{i}, '(.*?)/', 'tokens', 'ignorecase', 'match');
    model{i} = tok{1}{:};
    
    % Open Model if Needed
    % check if model is open, if not open it invisibly
    slOpen = model(~ismember(model{i},find_system));
    for m = 1:length(slOpen)
        load_system(slOpen{m});
    end
    
     % Pull out model path and variable
    [tok, mat] = regexp(Units{i}, '(.*?):', 'tokens', 'ignorecase', 'match');
    
    % Update Simulink Model
    if strcmpi(tok{2}{:},'value') % value block
        s = regexp(tok{1}{:},'/','split');
        set_param(tok{1}{:},tok{2}{:},num2str(ds.(s{2}),'%20.20g'));
    else
        set_param(tok{1}{:},tok{2}{:},num2str(ds.(tok{2}{:}),'%20.20g'));
    end
end

model = unique(model);

Contact us