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)

 Akzeptierte Antwort

dpb
dpb am 18 Jul. 2018

1 Stimme

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 Kommentare

jonas
jonas am 18 Jul. 2018
Much easier than my solution, nice!
AWi
AWi am 18 Jul. 2018
Perfect, thank you!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Produkte

Version

R2018a

Gefragt:

AWi
am 18 Jul. 2018

Kommentiert:

AWi
am 18 Jul. 2018

Community Treasure Hunt

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

Start Hunting!

Translated by