Index: mttroot/mtt/bin/trans/m/mtt_optimise.m ================================================================== --- mttroot/mtt/bin/trans/m/mtt_optimise.m +++ mttroot/mtt/bin/trans/m/mtt_optimise.m @@ -24,15 +24,15 @@ if nargin<6 weight = ones(size(y_s)); endif if nargin<7 - criterion = 1e-5; + criterion = 1e-7; endif if nargin <8 - max_iterations = 10; + max_iterations = 25; endif if nargin<9 alpha = 1.0; endif @@ -39,34 +39,60 @@ if (!strcmp(method,"time"))&&(!strcmp(method,"freq")) error("method must be either time or freq") endif - N_theta = length(free); - Weight = weight*ones(1,N_theta); # Sensitivity weight - e_last = 1e20; + [n_data,n_y] = size(y_s); + + n_th = length(free); + error_old = 1e20; error=1e10; theta = theta_0; Theta = []; Error = []; Y = []; iterations = -1; - while (abs(e_last-error)>criterion)&&(iterationscriterion)&&(iterationscriterion)&&(iterationserror_old+criterion # Halve step size and try again + factor = 10; + disp(sprintf("step/%i",factor)); + error = error_old; # Go back to previous error value + error_old = inf; # Don't let it think its converged + theta(free) = theta(free) + step; # Reverse step + step = step/factor; # new stepsize + else # Recompute step size + tol = 1e-5; + step = pinv(JJ,tol)*J; # Step size + #step = pinv(JJ)*J; # Step size (built in tol) + endif + theta(free) = theta(free) - step; # Increment parameters + endif + + endwhile endfunction