This is the automatic function wrapper ================================================================= ================ level-2 M file S-function ====================== ================================================================= To save as standalone variable(s) into global shared workspace the AO(s) received as input from the corresponding block, executed in Simulink. $Id: g_saveresult.m,v 1.1 2008/03/01 13:43:20 nicola Exp $
0001 function g_saveresult(block) 0002 0003 % This is the automatic function wrapper 0004 % ================================================================= 0005 % ================ level-2 M file S-function ====================== 0006 % ================================================================= 0007 % To save as standalone variable(s) into global shared workspace the AO(s) 0008 % received as input from the corresponding block, executed in Simulink. 0009 % 0010 % $Id: g_saveresult.m,v 1.1 2008/03/01 13:43:20 nicola Exp $ 0011 0012 setup(block); 0013 0014 %% 0015 function setup(block) 0016 global LTPDAinvar LTPDAoutvar 0017 0018 %% Register dialog parameter: none, because they're retrieved directly 0019 %% from the memory. This will prevent the user to modify the parameters 0020 %% outside the proper parameters panel: 0021 block.NumDialogPrms = 0; 0022 0023 %% Register number of input and output ports 0024 block.NumInputPorts = 1; 0025 block.NumOutputPorts = 1; 0026 0027 %% Setup functional port properties to dynamically inherited. 0028 block.SetPreCompInpPortInfoToDynamic; 0029 block.SetPreCompOutPortInfoToDynamic; 0030 0031 block.InputPort(1).DirectFeedthrough = true; 0032 block.InputPort(1).DatatypeID = 0; 0033 block.InputPort(1).Complexity = 0; 0034 % block.InputPort(1).Dimensions = 2; 0035 block.OutputPort(1).DatatypeID = 0; 0036 block.OutputPort(1).Complexity = 0; 0037 % block.OutputPort(1).Dimensions = 1; 0038 block.SampleTimes = [0 0]; 0039 block.SetAccelRunOnTLC(false); 0040 0041 %% Register methods 0042 block.RegBlockMethod('SetInputPortSamplingMode',@SetInpPortFrameData); 0043 block.RegBlockMethod('SetInputPortDimensions', @SetInpPortDims); 0044 block.RegBlockMethod('SetOutputPortDimensions', @SetOutPortDims); 0045 block.RegBlockMethod('Outputs', @Outputs); 0046 0047 function SetInpPortFrameData(block, idx, fd) 0048 block.InputPort(1).SamplingMode = fd; 0049 block.OutputPort(1).SamplingMode = fd; 0050 0051 function SetInpPortDims(block, idx, di) 0052 block.InputPort(idx).Dimensions = di; 0053 0054 function SetOutPortDims(block, idx, di) 0055 block.OutputPort(idx).Dimensions = di; 0056 0057 0058 %% 0059 function Outputs(block) 0060 global LTPDAinvar LTPDAoutvar 0061 0062 0063 % % Since the following sintax fails, due to a bug in the definition of AO 0064 % % class, it's temporary disabled. 0065 % % As a consequence the 'Save Result' block for now saves into the 0066 % % LTPDAoutvar array only the first AO coming in. 0067 % y = length(block.InputPort(1).Data); 0068 % resultArray = ao(); 0069 % for j=1:y 0070 % resultArray(j) = [resultArray,LTPDAinvar{block.InputPort(1).Data(j)}]; 0071 % end 0072 0073 xx = size(LTPDAoutvar,1); 0074 % LTPDAoutvar(xx+1,1) = {resultArray}; 0075 if xx==0, LTPDAoutvar{1,1} = LTPDAinvar{block.InputPort(1).Data(1)}; 0076 else LTPDAoutvar(xx+1,1) = LTPDAinvar(block.InputPort(1).Data(1)); 0077 end 0078 0079 % %======================================================================== 0080 0081 block.OutputPort(1).Data = block.InputPort(1).Data; 0082 0083 %endfunction 0084