I have fitted a curve to a data set with the fit funtion, see code below. In my graph I have the data points as well as the fitted function and would like display the function only up to a certain x-value (red arrow in figure). So that the last four points are still displayed but without the function intersecting them. Is that somehow possible??
c1 =[0.1000;
0.0750;
0.0500;
0.0250;
0.0100;
0.0090;
0.0080;
0.0070;
0.0060;
0.0050;
0.0040;
0.0030;
0.0020;
0.0010;
0.0005;
0.0001;
0.00001;
0.000001;
0]
d1=[46.5000;
46.4500;
47.5500;
46.9500;
47.0500;
48.6500;
48.9000;
49.0000;
51.0000;
51.9500;
58.3000;
62.1500;
66.5500;
68.1500;
71.1000;
71.4500;
71.1500;
70.9000;
70.2000]
f1 = fit(c1, d1, 'gauss3')
plot(f1, c1, d1)

 채택된 답변

dpb
dpb 2018년 7월 18일

1 개 추천

Yeah, but you have to evaluate the function over the range you want and use the results to do the plotting instead of the overloaded fit function-specific plot() routine--it doesn't have the option to not use the range of the data it was given for the prediction.
xhat=logspace(-6,-2); % 100 points log-spaced
yhat=f1(xhat); % evaluate at the points
semilogx(xhat,yhat,'r-',c1,d1,'b.') % plot the fit over range and all data points

댓글 수: 2

jonas
jonas 2018년 7월 18일
Much easier than my solution, nice!
AWi
AWi 2018년 7월 18일
Perfect, thank you!

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Interpolation에 대해 자세히 알아보기

제품

릴리스

R2018a

질문:

AWi
2018년 7월 18일

댓글:

AWi
2018년 7월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by