# Simple question about curve fitting

2 visualizaciones (últimos 30 días)
aurc89 el 4 de Abr. de 2015
Respondida: Geoff Hayes el 4 de Abr. de 2015
Hi everyone! I have a question about fitting a curve: I have two vectors x and y of same length and the curve y(x). I want to fit this curve with a gaussian and I use the command
fit(x,y,'gauss2')
How can I fit my curve with this function but only between two points (x1,y1) and (x2,y2), where x1,x2 are two elements of vector x and y1,y2 the corresponding values of vector y? thank you in advance
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

Geoff Hayes el 4 de Abr. de 2015
aurc89 - find the indices of x1 and x2 within your x vector and then fit the curve against x and y using these indices. For example, if idx1 and idx2 are the indices of x1 and x2 such that x(idx1)==x1 and x(idx2)==x2 then fit the curve between these two points as
fit(x(idx1:idx2),y(idx1:idx2),'gauss2')
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Categorías

Más información sobre Linear and Nonlinear Regression en Help Center y File Exchange.

### Community Treasure Hunt

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

Start Hunting!

Translated by