fitting error, how to fix it

I am trying to run the following code, and get the error, please advice how to fix it, thank you.
x = (0:0.2:5)';
y = 2*exp(-0.2*x) + 0.1*randn(size(x));
f = fit(x,y,'exp1')
plot(f,x,y)
"Subscript indices must either be real positive integers or logicals."

 Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 16 de Jul. de 2014

0 votos

Probably, you have used fit as a variable in your code
Try this
clear fit
x = (0:0.2:5)';
y = 2*exp(-0.2*x) + 0.1*randn(size(x));
f = fit(x,y,'exp1')
plot(f,x,y)

Más respuestas (0)

Categorías

Más información sobre Linear and Nonlinear Regression en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 16 de Jul. de 2014

Respondida:

el 16 de Jul. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by