KerMor  0.9
Model order reduction for nonlinear dynamical systems and nonlinear approximation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Fuglevand.m
Go to the documentation of this file.
1 namespace models{
2 namespace motorunit{
3 
4 
5 /* (Autoinserted by mtoc++)
6  * This source code has been filtered by the mtoc++ executable,
7  * which generates code that can be processed by the doxygen documentation tool.
8  *
9  * On the other hand, it can neither be interpreted by MATLAB, nor can it be compiled with a C++ compiler.
10  * Except for the comments, the function bodies of your M-file functions are untouched.
11  * Consequently, the FILTER_SOURCE_FILES doxygen switch (default in our Doxyfile.template) will produce
12  * attached source files that are highly readable by humans.
13  *
14  * Additionally, links in the doxygen generated documentation to the source code of functions and class members refer to
15  * the correct locations in the source code browser.
16  * However, the line numbers most likely do not correspond to the line numbers in the original MATLAB source files.
17  */
18 
19 class Fuglevand
20  :public handle {
39  public:
40 
41  fsamp = 1000;
48 len = 10;
56  RR = 30;
63  fmin = 8;
70 fmax = 35;
78  sd_ISI = 0.1;
86  RP = 100;
93 RT = 3;
101  lengthWin = 1000;
109  Resolution = 100;
110 
111 
112  public:
113 
115 
116 
117  private:
118 
119  r;
120 
121  fSeed;
122 
123 
124  public: /* ( Dependent ) */
125 
127 
128 
129  public: /* ( Dependent ) */
130 
132  this.pende= (this.fmax-this.fmin)/60; /* gain g_e in the paper */
133 
134 
135  this.Seed= 1;
136  }
144  function forces = getForces(colvec<double> mu,T) {
145 
146  if nargin < 3
147  T = 2000;
148  if nargin < 2
149  mu = [.1 5];
150  end
151  end
152 
153  /* Add window of single peak to simulation time */
154  T = T + this.lengthWin;
155 
156  firing = zeros(1,T);
157  forces = firing;
158 
159  k = 2;
160  gain = 1;
161 
162  /* recruitment threshold excitation */
163  rte = exp(log(this.Resolution)*mu(1))*this.RR/this.Resolution;
164  exDrive = mu(2)*this.RR/10;
165 
166  if rte <= exDrive*1.001
167 
168  /* peak twitch force */
169  P = exp(log(this.Resolution)*mu(1))*this.RP/this.Resolution;
170  Tfac = 90*(1./P)^(log(this.RT)/log(this.RP));
171 
172  /* instantaneous discharge frequency */
173  finst = this.pende*(exDrive-rte)+this.fmin;
174  finst = min(finst, this.fmax);
175 
176  /* previous firing time
177  * rand is a pseudorandom value drawn from the standard uniform distribution on the open interval (0,1). */
178  istprec = this.r.rand/finst;
179 
180  istatt = 0; /* current firing time */
181 
182  while(istatt+0.02 < T/1000)
183  /* variability due to the jitter
184  * standard normal distri with mean 0 and standard deviation sd_ISI
185  * rand is a pseudorandom value drawn from the standard normal distribution */
186  var_jitter = this.sd_ISI*this.r.randn*0;
187 
188  /* moment of activation (time) */
189  istatt = istprec+(1+var_jitter)/finst;
190  /* check that the firing is not too close to the previous one */
191  if(istatt < istprec+0.02)
192  istatt = istprec+0.02;
193  end
194  firing(round(istatt*1000)) = 1;
195  Ti_ISI = Tfac/(istatt-istprec)/1000;
196  if(Ti_ISI < 0.4)
197  gain(k) = 1.0;/* #ok */
198 
199  else
200  gain(k) = (1-exp(-2*Ti_ISI^3))/Ti_ISI/((1-exp(-2*0.4^3))/0.4);/* #ok */
201 
202  end
203  k=k+1;
204  istprec = istatt;
205  end /* while */
206 
207  hlp = [0:round(this.lengthWin/1000*this.fsamp)]/this.fsamp/(Tfac/1000);
208  winCoeff = P.*(hlp.*exp(1-hlp));
209  winCoeff = [0 winCoeff(winCoeff>1.e-4)];
210 
211  spikes = find(firing==1);
212  for i=1:size(spikes,2)
213  if(spikes(i)+size(winCoeff,2) <= length(forces))
214  idx = spikes(i) + (1:size(winCoeff,2));
215  forces(idx) = forces(idx)+gain(i)*winCoeff;
216  end
217  end
218  end
219  /* Subtract window of single peak from force */
220  forces = forces(1:end-this.lengthWin);
221  }
222 
223 
224 
225 #if 0 //mtoc++: 'set.Seed'
226 function Seed(value) {
227  this.r= RandStream(" mt19937ar "," Seed ",value);
228  this.fSeed= value;
229  }
230 
231 #endif
232 
233 
234 
235 #if 0 //mtoc++: 'get.Seed'
236 function value = Seed() {
237  value = this.fSeed;
238  }
239 
240 #endif
241 
242 
243  public: /* ( Static ) */ /* ( Dependent ) */
244 
245  static function test_ForceResponse() {
246  f = models.motorunit.Fuglevand;
247  [x,y] = meshgrid(0:.05:1,0:.4:10);
248  p = [x(:) y(:)]^t;
249  force = zeros(1,numel(x));
250  for k=1:size(p,2)
251  fmu = f.getForces(p(:,k));
252  force(k) = max(fmu);
253  end
254  force = reshape(force,size(x,1),[]);
255  surf(x,y,force," FaceColor "," interp "," EdgeColor "," interp ");
256  }
257 
258 
264 };
265 }
266 }
267 
RR
range of recruitment threshold values
Definition: Fuglevand.m:56
function forces = getForces(colvec< double > mu, T)
Definition: Fuglevand.m:144
lengthWin
duration of a single twitch in [ms]
Definition: Fuglevand.m:101
fsamp
sampling rate [samples / s]
Definition: Fuglevand.m:41
static function test_ForceResponse()
Definition: Fuglevand.m:245
reshape
hanges the dimensions of the handle object array to the specified dimensions. See the MATLAB reshape ...
Fuglevand()
Defines the frequency change will know how to increase the level of the contraction frequency becomes...
Definition: Fuglevand.m:131
Matlab's base handle class (documentation generation substitute)
fmax
max discharge rate
Definition: Fuglevand.m:70
RT
range of contraction times RT
Definition: Fuglevand.m:93
RP
range of twitch forces RP
Definition: Fuglevand.m:86
fmin
min discharge rate
Definition: Fuglevand.m:63
len
length of stimulation in [s]
Definition: Fuglevand.m:48
sd_ISI
Standard dev. of ISI [Standard dev. del Jitter medio].
Definition: Fuglevand.m:78