If I have performed a cubic interp to some data,
x = linspace(1,maxFwhm+1,maxFwhm+1)'
f=fit(x,y,'cubicinterp')
hold on
plot(f,'k--')
coeffvalues(f)
How can I now calculate the x value that corresponds with the y value of 0.5?
Thanks Jason

 채택된 답변

Steven Lord
Steven Lord 2017년 1월 13일

0 개 추천

Use fzero to solve f(x) = 0.5. Keep in mind you can evaluate the fit by passing it a value.
load census
populationFit = fit(cdate, pop, 'poly2');
populationIn1925 = populationFit(1925)
You can check that it evaluated the fit correctly.
plot(cdate, pop)
hold on
plot(populationFit)
plot(repmat(1925, 1, 2), ylim)
plot(xlim, repmat(populationIn1925, 1, 2))
plot(1925, populationIn1925, 'o')

댓글 수: 3

Hi, Im not sure I follow how your suggesting I use fzero.
I have tried:
fun=f-0.5;
x0 = [3 5];
myx = fzero(fun,x0)
But didn't work.
You need to make sure you evaluate the fit for a specific value that fzero will pass into your function.
fun = @(x) f(x)-0.5;
Jason
Jason 2017년 1월 13일
Thankyou

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

추가 답변 (1개)

John D'Errico
John D'Errico 2017년 1월 13일
편집: John D'Errico 2017년 1월 13일

0 개 추천

Download my SLM Toolbox . Since I don't have your data, I'll make some up. Not a very creative function, I know, but it will suffice.
Here, for which values of x does the function equal 0.5?
x = (0:5)';
y = rand(size(x));
y = rand(size(x))
y =
0.79221
0.95949
0.65574
0.035712
0.84913
0.93399
f=fit(x,y,'cubicinterp');
slmsolve(f.p,0.5)
ans =
2.1967 3.671
The results are as good as can be had (using the function roots), not an approximation.

카테고리

도움말 센터File Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기

질문:

2017년 1월 13일

댓글:

2017년 1월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by