Display only part of a plot?

25 visualizaciones (últimos 30 días)
AWi
AWi el 18 de Jul. de 2018
Comentada: AWi el 18 de Jul. de 2018
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)

Respuesta aceptada

dpb
dpb el 18 de Jul. de 2018
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 comentarios
jonas
jonas el 18 de Jul. de 2018
Much easier than my solution, nice!
AWi
AWi el 18 de Jul. de 2018
Perfect, thank you!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Interpolation en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by