Display only part of a plot?

27 次查看(过去 30 天)
AWi
AWi 2018-7-18
评论: AWi 2018-7-18
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
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 个)

类别

Help CenterFile Exchange 中查找有关 Interpolation 的更多信息

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by