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
ParamDomainDetection.m
Go to the documentation of this file.
1 namespace models{
2 namespace motoneuron{
3 namespace experiments{
4 
5 
6 /* (Autoinserted by mtoc++)
7  * This source code has been filtered by the mtoc++ executable,
8  * which generates code that can be processed by the doxygen documentation tool.
9  *
10  * On the other hand, it can neither be interpreted by MATLAB, nor can it be compiled with a C++ compiler.
11  * Except for the comments, the function bodies of your M-file functions are untouched.
12  * Consequently, the FILTER_SOURCE_FILES doxygen switch (default in our Doxyfile.template) will produce
13  * attached source files that are highly readable by humans.
14  *
15  * Additionally, links in the doxygen generated documentation to the source code of functions and class members refer to
16  * the correct locations in the source code browser.
17  * However, the line numbers most likely do not correspond to the line numbers in the original MATLAB source files.
18  */
19 
21 MinHz = 10;
22 MaxHz = 60;
23 /* Depending on sample simulations, an upper limit polynomial is computed.
24  * Here, the fibre type and mean activation current along the 60Hz-contour
25  * are used to fit a polynomial that yields the maximum mean input current
26  * for any fibre type. */
27 
28 basedir = fileparts(mfilename(" fullpath "));
29 
30 /* m = models.motoneuron.Model;
31  * m.T = 432; % [ms]
32  * m.UseNoise = true;
33  *
34  * m.System.Params(1).Range = [0 1];
35  * m.System.Params(2).Range = [.5 9];
36  *
37  * ns = 5000;
38  * m.Sampler.Samples = ns;
39  * m.Sampler.Seed = 1;
40  *
41  * m.off1_createParamSamples;
42  *
43  * %% Datagen
44  * ct = zeros(1,ns);
45  * Hz = -Inf(1,ns);
46  *
47  * pi = ProcessIndicator('Assembling frequency data',ns,false);
48  * % for k = 1 : ns
49  * parfor k = 1 : ns
50  * [t,y,ct(k)] = m.simulate(m.Data.ParamSamples(:,k),1);%#ok
51  *
52  * % Finde anzahl peaks
53  * np = 0;
54  * sign = y(2,:) > 50;
55  * if any(sign)
56  * % Strategie: finde die indices der daten > 50, und stelle fest wie viele sprünge (abstand
57  * % >5 in diskreten zeiteinheiten) darin vorhanden sind.
58  * np = 1 + length(find(diff(find(sign)) > 5));
59  * end
60  * % Mittlere frequenz
61  * Hz(k) = (np/m.T)*1000; % [Hz]
62  * pi.step;%#ok
63  * end
64  * pi.stop;
65  * m.save;
66  * ps = m.Data.ParamSamples;
67  * modeldir = m.Data.DataDirectory;
68  *
69  * % Colormap
70  * mHz = min(Hz);
71  * MHz = max(Hz);
72  * detail = linspace(mHz,MHz,1000);
73  * ncol = length(detail);
74  * r = zeros(ncol,1);
75  * g = zeros(ncol,1);
76  * b = zeros(ncol,1);
77  *
78  * % Eff min to MinHz
79  * [~,minpos] = min(abs(detail-MinHz));
80  * toolow = 1:minpos;
81  * g(toolow) = linspace(0,.5,length(toolow));
82  * b(toolow) = linspace(1,0,length(toolow));
83  *
84  * % MaxHz to eff max
85  * [~,maxpos] = min(abs(detail-MaxHz));
86  * toohigh = maxpos:ncol;
87  * r(toohigh) = linspace(.5,1,length(toohigh));
88  * b(toohigh) = linspace(0,.1,length(toohigh));
89  *
90  * % Intermediate
91  * good = minpos:maxpos;
92  * g(good) = .9;
93  * r(good) = linspace(.4,.9,length(good));
94  * cmap = [r g b];
95  *
96  * %% Compute upper limit polynomial
97  * ft1 = 0:.005:1;
98  * mc1 = .5:.05:9;
99  * [ft,mc] = meshgrid(ft1,mc1);
100  * iHz = griddata(ps(1,:),ps(2,:),Hz,ft,mc);
101  * [i,j] = find(iHz > MaxHz);
102  * [j,ftcolidx] = unique(j);
103  * i = i(ftcolidx);
104  * x_ft = ft1(j);
105  * fx_mc = mc1(i);
106  * upperlimit_poly = polyfit(x_ft,fx_mc,3);
107  *
108  * save(fullfile(basedir,'paramdomaindetection_withnoise'), 'ct', 'modeldir', 'ps', 'Hz', 'cmap', 'MinHz', 'MaxHz','upperlimit_poly','x_ft','fx_mc');
109  * save(models.motoneuron.Model.FILE_UPPERLIMITPOLY, 'upperlimit_poly'); */
110 
111 /* % Plots */
112 load(fullfile(basedir," paramdomaindetection_withnoise "));
113 
114 pm = PlotManager;
115 pm.LeaveOpen= true;
116 h = pm.nextPlot(" motoparamstudy "," Motoneuron firing rate in Hz for different parameters "," fibre_type "," mean_current_factor ");
117 tri = delaunay(ps(1,:),ps(2,:));
118 trisurf(tri,ps(1,:),ps(2,:),Hz," FaceColor "," interp "," EdgeColor "," interp ");
119 tricontour(gca, tri, ps" , Hz ",linspace(MinHz,MaxHz,5));
120 colormap(cmap);
121 
122 h = pm.nextPlot(" upperlimitpoly "," Upper limit for mean current dependent on fibre type "," fibre_type "," mean_current_factor ");
123 plot(h,x_ft,fx_mc," b ",ft1,polyval(upperlimit_poly,ft1)," r ");
124 
125 pm.done;
126 }
141 };
142 };
143 };
* polyval(pol, slen)
function [ cout , hout ] = tricontour(ax,double t, p, Hn, N, varargin)
Definition: tricontour.m:17
PlotManager: Small class that allows the same plots generated by some script to be either organized a...
Definition: PlotManager.m:17
logical LeaveOpen
Flag indicating if the plots should be left open once the PlotManager is deleted (as variable) ...
Definition: PlotManager.m:213
function ParamDomainDetection()
% Setup This script is used to detect a physically reasonable parameter domain for the motoneuron mod...