diff m-toolbox/m/gui/gltpda/g_resp.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/m/gui/gltpda/g_resp.m	Wed Nov 23 19:22:13 2011 +0100
@@ -0,0 +1,76 @@
+function g_resp(block)
+
+%  $Id: g_resp.m,v 1.1 2008/03/01 13:43:20 nicola Exp $
+
+setup(block);
+  
+%%
+function setup(block)
+
+  %% Register dialog parameter: none, because they're retrieved directly
+  %% from the memory. This will prevent the user to modify the parameters
+  %% outside the proper parameters panel:
+  block.NumDialogPrms = 0;
+
+  %% Register number of input and output ports
+  block.NumInputPorts  = 1;
+  block.NumOutputPorts = 1;
+
+  %% Setup functional port properties to dynamically inherited.
+  block.SetPreCompOutPortInfoToDynamic;
+  
+  block.InputPort(1).DirectFeedthrough = true;
+  block.InputPort(1).DatatypeID = 0;
+  block.InputPort(1).Complexity = 0;
+  block.InputPort(1).SamplingMode = 'sample';
+  block.OutputPort(1).DatatypeID = 0;
+  block.OutputPort(1).Complexity = 0;
+  block.OutputPort(1).Dimensions = 1;
+  block.OutputPort(1).SamplingMode = 'sample';
+  block.SampleTimes = [0 0];
+  block.SetAccelRunOnTLC(false);
+  
+  
+
+  %% Register methods
+  block.RegBlockMethod('SetInputPortSamplingMode',@SetInpPortFrameData);
+  block.RegBlockMethod('SetInputPortDimensions',  @SetInpPortDims);
+% block.RegBlockMethod('SetOutputPortDimensions', @SetOutPortDims);
+  block.RegBlockMethod('Outputs',                 @Outputs);
+
+   function SetInpPortDims(block, idx, di)
+  block.InputPort(idx).Dimensions = di;
+
+    function SetInpPortFrameData(block, idx, fd)
+  block.InputPort(1).SamplingMode = fd;
+  block.OutputPort(1).SamplingMode = fd;
+  
+%  function SetOutPortDims(block, idx, di)
+% block.OutputPort(idx).Dimensions = 1;
+
+
+%%
+function Outputs(block)
+global LTPDAinvar
+
+  
+  currhandle=gcbh;
+  currparent=get_param(currhandle,'Parent');
+  
+  paramcommand = get_param(currparent,'Description');
+  eval(paramcommand)
+  
+  
+  
+  data = get(params.params(1),'val');
+  aodata = find(params,'AO data');
+  if ~isempty(aodata)
+      currparam = LTPDAinvar{block.InputPort(1).Data,1}.data.x;
+  end
+  
+  outdata=resp(data,currparam);
+  outdata = num2cell(outdata);
+
+  xx = size(LTPDAinvar,1);
+  LTPDAinvar(xx+1,:) = [outdata,0];
+  block.OutputPort(1).Data = xx+1;