Why is polyfit giving me "NAN"

Hello,
I am curious why polyfit is returning 'nan'. My data set is finite and positive. I am attempting to study a power function and use it for my data. so here is what I have:
p = polyfit(log(x), log(y), 1);
However, I keep getting:
p = [nan nan] The dimensions of x and y are 1 column and 2617 rows
Please help and thank you so much!!

4 Comments

Range issue w/ log, most likely?
What is min(log()) and max for x, y?
You can try the scaling option to see if helps the numerics...
W/o a dataset, tough to say much more than "that's what the data say", sorry.
Do you possibly have duplicate x ?
Does x or y have 0, or negative numbers, or nan's in them?
I think you have zeros in X or Y. so log(0)=-inf. Try with cftool.
Regards.

Sign in to comment.

Answers (0)

Asked:

on 30 Jun 2016

Commented:

on 30 Jun 2016

Community Treasure Hunt

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

Start Hunting!