64 if ~isempty(max_modulus)
70 pts = linspace(1,rightval,3);
73 maxit = ceil(log((pts(3)-pts(1))/eps)/log(2));
75 while diff > sqrt(eps) && it < maxit;
78 pts = [pts(2) (pts(2)+pts(3))/2 pts(3)];
80 pts = [pts(1) (pts(1)+pts(2))/2 pts(2)];
89 if rightval-pts(2) < 1e-10
90 rightval = rightval*2;
97 fprintf(
" Found t0=%5.3g with diff %g to max modulus/derivative of %g after %d iterations (b=%g, d=%g).\n ",...
98 this.t0,diff,max_modulus,it,b,d);
105 function [fhandle , dfhandle , fbdhandle , dfbdhandle ] =
getFunction() {
114 fhandle = @(
t)(
t >= 1 &
t<tlin).*(b1./
t.^2.*(
t.^d1-1).*(
t-1).^2)...
115 + (
t>=tlin).*(ftlin + mm*(
t-tlin));
116 dfhandle = @(
t)(
t >= 1 &
t<tlin).*(b1.*(
t-1)./
t.^3.*((d1*(
t-1)+2).*
t.^d1-2)) ...
118 fbdhandle = @(
t,b1,d1)(
t >= 1 &
t<tlin).*(b1./
t.^2.*(
t.^d1-1).*(
t-1).^2)...
119 + (
t>=tlin).*(ftlin + mm*(
t-tlin));
120 dfbdhandle = @(
t,b1,d1)(
t >= 1 &
t<tlin).*(b1.*(
t-1)./
t.^3.*((d1*(
t-1)+2).*
t.^d1-2)) ...
125 fhandle = @(
t)(
t>=1).*(b1./
t.^2.*(
t.^d1-1).*(
t-1).^2);
126 dfhandle = @(
t)(
t>=1).*b1.*(
t-1)./
t.^3.*((d1*(
t-1)+2).*
t.^d1-2);
127 fbdhandle = @(
t,b1,d1)(
t>=1).*(b1./
t.^2.*(
t.^d1-1).*(
t-1).^2);
128 dfbdhandle = @(
t,b1,d1)(
t>=1).*b1.*(
t-1)./
t.^3.*((d1*(
t-1)+2).*
t.^d1-2);
134 str = sprintf(
" b: %g, d: %g, MaxModulus:%g ",this.
b,this.
d,this.
max_modulus);
141 range = [1 1.2*this.
t0];
146 plot@general.functions.AFunGen(
this,
" R ", range, varargin[:]);
147 if (range(2) > this.
t0)
148 ax =
get(gcf,
" Children ");
152 plot(ax,this.
t0,this.
ft0,
" rx ",
" MarkerSize ",16);
161 x = linspace(.3,6,300);
164 ax = pm.nextPlot(
" markertfun_lintest ",
" Plots for various parameters ",
" lambda ",
" value ");
165 axl = pm.nextPlot(
" markertfun_lintest_log ",
" Plots for various parameters ",
" lambda ",
" value ");
167 ml = models.muscle.functions.MarkertLaw(C(1,i),C(2,i),C(3,i));
169 [f,df] = ml.getFunction;
172 semilogy(axl,x,fx,
" b ");
173 fprintf(
" t0=%g, f(t0)=%g for %s\n ",ml.t0, ml.ft0, ml.getConfigStr);
178 ml = models.muscle.functions.MarkertLaw(C(1,i),C(2,i),[]);
180 [f,df] = ml.getFunction;
183 semilogy(axl,x,fx,
" r ");
194 orig = models.muscle.functions.MarkertLawOriginal(7990, 16.6);
200 linspace(orig.b/fac,orig.b*fac*1000,ntest),...
201 linspace(orig.d/fac,orig.d*fac,ntest));
202 l = linspace(range(1),range(2),100);
203 of = orig.getFunction;
209 m = models.muscle.functions.MarkertLaw(p(1,
k),p(2,
k));
212 err(
k) = norm(forig-ftest);
216 [~, idx] = min(err(1,:));
217 fit = models.muscle.functions.MarkertLaw(p(1,idx),p(2,idx));
218 fitlin = models.muscle.functions.MarkertLaw(p(1,idx),p(2,idx),1e5);
220 fit.plottofigure(gcf,
l,
" P ",[
" r "]);
221 fitlin.plottofigure(gcf,
l,
" P ",[
" g "]);
Collection of generally useful functions.
static function comb = createCombinations(ranges, varargin)
Creates the cartesian product of the vectors passed as a matrix containing elements of each vector pe...
function str = getConfigStr()
function plot(range, varargin)
Returns the modified markert law functions for the OVERALL energy density funcion derivative w...
PlotManager: Small class that allows the same plots generated by some script to be either organized a...
MarkertLaw(b, d, max_modulus)
static const LatestLinearizationLambda
static function [ res , fit , fitlin ] = test_FitToOriginal(orig, range)
A variable number of input arguments.
static function test_Linarization()
AFUNGEN Summary of this class goes here Detailed explanation goes here.
function [ fhandle , dfhandle , fbdhandle , dfbdhandle ] = getFunction()
ProcessIndicator: A simple class that indicates process either via waitbar or text output...