26 file = fullfile(fileparts(mfilename(
" fullpath ")),
" ic_singletwitch.mat ");
27 filex0 = fullfile(fileparts(mfilename(
" fullpath ")),
" .. ",
" x0coeff ");
28 if exist(file,
" file ") == 2
31 m = models.motorunit.Shorten(
false,
true);
33 s = sampling.ManualSampler;
34 p = linspace(0,1,200);
35 p = [p; ones(size(p))*1];
38 m.off1_createParamSamples;
45 endvals = zeros(m.System.f.xDim,n);
47 pi =
ProcessIndicator(
" Running %d simulations with one twitch ",n/(max(1,matlabpool(
" size "))),
false,n);
50 [
t, y, ctimes(k), x] = m.simulate(p(:,k),1);
52 endvals(:,k) = x(:,end);
57 m.Data.TrajectoryData.consolidate(m);
60 save(file,
" m ",
" endvals ",
" p ",
" ctimes ");
65 dim = size(endvals,1);
66 coeff = zeros(dim,deg+1);
68 a = dscomponents.AffineInitialValue;
71 coeff(k,:) = polyfit(p(1,:),endvals(k,:),deg);
73 a.addMatrix(sprintf(
" polyval([%s],mu(1)) ",sprintf(
" %g ",coeff(k,:))),full(sparse(k,1,1,dim,1)));
79 endvals_afflin = zeros(size(endvals));
81 endvals_afflin(:,k) = a.evaluate(p(1,k));
83 semilogy(p(1,:),
Norm.
L2(endvals_afflin-endvals)./
Norm.
L2(endvals));
84 title(sprintf(
" Relative errors of initial values for %d increasing mu_1 ",n));
86 save(file,
" a ",
" endvals_afflin ",
" err ",
" coeff ",
" -APPEND ");
87 save(filex0,
" coeff ");
static function rowvec< double > n = Linf(matrix< double > x)
Returns the discrete norm for each column vector in x.
function InitialConditions()
% Old version: This script runs the motorunit.Model instance without input for 10 seconds...
static function rowvec< double > n = L2(matrix< double > x)
Returns the discrete norm for each column vector in x.
Norm: Static class for commonly used norms on sets of vectors.
ProcessIndicator: A simple class that indicates process either via waitbar or text output...