www.gusucode.com > mbcdesign 工具箱 matlab 源码程序 > mbcdesign/@conbase/slSetParameters.m
function slSetParameters(con, sys) %SLSETPARAMETERS Sets the parameters for a Simulink model of a constraint. % % SLSETPARAMETERS(CON, SYS) % % Each constraint must provide it's own version of PSLGETPARAMETERS. This % methods returns a structure with all the required parameters. % % We write this set method separately from the method for getting the % parameters so that we may easily change how the blocks store the parameter % information. % % See also CONBASE, CONBASE/SLBLOCK, CONBASE/PSLGETPARAMETERS. % Copyright 2005-2007 The MathWorks, Inc. % Get up user data structure for this constraint ud = pslGetParameters( con ); if ~isempty( ud ), % The initialization command has to get all of the data from the user % structure and assign it to the variables that the block is expecting fn = fieldnames( ud ); nFields = length( fn ); maskInitialization = cell( nFields, 1 ); for i = 1:nFields, maskInitialization{i} = sprintf( '%s = ud.%s; ', fn{i}, fn{i} ); end maskInitialization = strcat( ... 'ud = get_param( gcb, ''UserData'' ); ', ... maskInitialization{:} ); % Assign the user data to the block set_param( sys, 'UserData', ud ); set_param( sys, 'UserDataPersistent', 'on' ); set_param( sys, 'MaskInitialization', maskInitialization ); end %------------------------------------------------------------------------------| % EOF %------------------------------------------------------------------------------|