function mttWriteSystemDefinitions(model) def.structure = define_data_structures(model) ; def.covar = define_bond_covariables(model) ; def.var = define_interface_covariables(model) ; def.sympar = define_symbolic_parameters(model) ; def.numpar = define_numerical_parameters(model) ; def.input = define_input_variables(model) ; def.state = define_state_variables(model) ; def.opvar = define_operator_variables(model) ; write_definitions(def,model) ; function code = define_data_structures(model) mttNotify('...defining data structures') ; mttWriteNewLine ; code = [] ; line = 0 ; tab = char(32*ones(1,3)) ; line = line + 1 ; code{line} = ['typedef struct {'] ; line = line + 1 ; code{line} = [tab,'double state,derivative ;'] ; line = line + 1 ; code{line} = ['} mttState ;'] ; line = line + 1 ; code{line} = '' ; line = line + 1 ; code{line} = ['typedef struct {'] ; line = line + 1 ; code{line} = [tab,'double effort,flow ;'] ; line = line + 1 ; code{line} = ['} mttGenericDomain ;'] ; line = line + 1 ; code{line} = '' ; domain_names = mttGetFieldNames(model.env,'domain') ; for i = 1:length(domain_names) domain_name = domain_names{i} ; domain = getfield(model.env,'domain',domain_name) ; public_domain = model.env.public_domain(domain.dom) ; item_names = mttGetFieldNames(public_domain,'item') ; if isempty(domain.item) first = 1 ; last = length(item_names) ; else first = strmatch(domain.item,item_names,'exact') ; last = first ; end for j = first:last item_name = item_names{j} ; covariables = getfield(public_domain,'item',item_name) ; line = line + 1 ; code{line} = ['typedef struct {'] ; for k = 1:length(covariables.effort) line = line + 1 ; effort_covariable = strrep(covariables.effort{k},'.','__') ; flow_covariable = strrep(covariables.flow{k},'.','__') ; code{line} = [tab,'double ',effort_covariable,',',flow_covariable,' ;'] ; end definition = ['} mttDomain__',domain_name] ; if isempty(domain.item) definition = [definition,'__',item_name] ; end definition = [definition,' ;'] ; line = line + 1 ; code{line} = definition ; if j