How to skip the element that is 'inf' value where fitting a curve
    4 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    KB
 el 18 de Ag. de 2014
  
    
    
    
    
    Comentada: Star Strider
      
      
 el 19 de Ag. de 2014
            Hello, I have been trying to get some constant values for a given set of experimental data. The fitting equation is below:
k*t = a-ln((Cm/C)-1) where a and k value needs to be find out. C is the output at different time t. Cm = maximum value of the C data at anytime t. So, obviously at some point ln((Cm/C)-1) is giving me 'inf' value and the procedure is not able to initiate at any initial guess of k and a value.
How to proceed with the problem for the solution. I have been trying using 'lsqcurvefit' which says 'Objective function is returning undefined values at initial point. lsqcurvefit cannot continue'
0 comentarios
Respuesta aceptada
  Star Strider
      
      
 el 18 de Ag. de 2014
        
      Editada: Star Strider
      
      
 el 18 de Ag. de 2014
  
      I would use this equation for ‘Cfit’ as my objective function:
% b(1) = a,  b(2) = k,  <— Designate Parameter Vector ‘b’
Cm = ...    % <— Supply a value for ‘Cm’
Cfit = @(b,t,Cm) Cm./(exp(b(1)-b(2).*t) + 1);   % Objective Function
b0 = rand(2,1);                                 % Initial Parameter Estimate
B = lsqcurvefit(@(b,t) Cfit(b,t,Cm), b0, t, C)  % Estimate Parameters
a = B(1);
k = B(2);
That should work. (Tested with simulated data for ‘t’ and ‘C’.)
You needed to solve for ‘C’ as a function of ‘t’ to make it work. (It’s a three or four line derivation.)
2 comentarios
  Star Strider
      
      
 el 19 de Ag. de 2014
				My pleasure!
‘Cfit’ is the function (as an anonymous function here) that fits your data. (It is known as the ‘objective function’ in nonlinear parameter estimation terms.) It is your original expression, solved for ‘C’ as a function of ‘t’, specifically:
C(t) = Cm /(exp(a-k*t)+1)
however it has to be stated slightly differently in anonymous function form, and in its use in lsqcurvefit, for it to work in MATLAB to fit your data. See the documentation on Anonymous Functions for details.
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

