custom equation fit in curveFitter is not working
    조회 수: 11 (최근 30일)
  
       이전 댓글 표시
    
I'm looking to do a "custom equation" fit using the curveFitter in matlab with this data:
pc2 = 
         0
    0.0001
    0.0011
    0.0216
    0.2847
    0.8708
    1.0000
lam_2 =
     0
    30
    55
   110
   200
   320
   460
After opening curveFitter, I load lam_2 as my X and pc2 as my Y.
My custom equation is: 0.5*(1+erf(b*(x-a)))
One time I got a good fit by choosing a good initial value, MATLAB calculated a to be a = 240.4
Now I wanted to recreate this fit and I'm choosing 240.4 or even numbers around that value as my starting point for "a" and the fit doesnt work anymore. 
댓글 수: 3
  Torsten
      
      
 2023년 1월 30일
				I didn't know you can give an initial value to only one of the parameters to be fitted. And in my opinion - if MATLAB chooses the second one arbitrarily - it also doesn't make much sense. Better you plot the curve for your guessed parameters first before using the fitting tool.
채택된 답변
  Torsten
      
      
 2023년 1월 30일
        
      편집: Torsten
      
      
 2023년 1월 30일
  
      pc2 = [ 0
    0.0001
    0.0011
    0.0216
    0.2847
    0.8708
    1.0000];
lam_2 = [ 0
    30
    55
    110
    200
    320
    460];
hold on
plot(lam_2,pc2,'o')
fun = @(x,a,b)0.5*(1+erf(b*(x-a)));
a = 1000;
b = 1/2000;
sol = lsqcurvefit(@(x,xdata)fun(xdata,x(1),x(2)),[a b],lam_2,pc2)
x = linspace(min(lam_2),max(lam_2),100);
plot(x,fun(x,sol(1),sol(2)))
hold off
grid on
추가 답변 (0개)
참고 항목
카테고리
				Help Center 및 File Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


