필터 지우기
필터 지우기

Continuous Piecewise Function in Anonymous Fittype Equation

조회 수: 10 (최근 30일)
Scott
Scott 2011년 12월 20일
Hey guys, This will (hopefully) be my last question I have on here. Had mixed luck so far. Basically what I have right now is an anonymous function with a fittype command followed by a fit command.
For example:
f = fittype('equation... etc.);
[c2,gof2]=fit(xdata,ydata,f,... etc.);
Right now the equation is a sum of various gaussians, easy enough to pass. However I need to modify this, I need to add in piecewise functions.
What I mean by that is I need (in English not Math lingo):
For x<B: y = straight line,
For y>=B y = gaussian
The straight line is at the top of the gaussian so the overall equation is continuous and differentiable. However, I am unsure how this would work in a fittype command and what I can do to get it to work.
A thought:
- Any way to define a function prior to the fittype command that is this piecewise function, say p(x), then just put 'p(x)' inside the fittype command using the variables of p(x) as "coefficients" to fit the equation.
Thanks to anyone who replies. This is the final hurdle for my project so mucho appreciado!
  댓글 수: 2
bym
bym 2011년 12월 20일
what does this mean "The straight line is at the top of the gaussian so the overall equation is continuous and differentiable." Can you draw a picture & post?
Walter Roberson
Walter Roberson 2011년 12월 20일
http://www.mathworks.com/matlabcentral/answers/7924-where-can-i-upload-images-and-files-for-use-on-matlab-answers

댓글을 달려면 로그인하십시오.

채택된 답변

Scott
Scott 2011년 12월 21일
((x>0 & x<=xa).*(A)+(x>=xa & x<100).*(A.*exp(-2.77.*((x-xa).^2)./B./B)))
Basically have (Limits Function Exists).*Function + (Limit Function Exists).*Function etc.
This is all inside the fittype command.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear and Nonlinear Regression에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by