How to fit the best line
Show older comments
Hello,
I have a problem trying to choose out of two vectors the one vector that is most similar to a sample vector. My function receives a couple of vectors and a sample vector every time. It then needs to compare each one of them to the sample, and choose the best fit. The vectors represent lines and the values in each vector represent the line's dots, so actually I need to fit the best line pattern to the sample.
My problem is that sometimes I need to fit a vector of zeros to a vector of very small values. So, for example if the two vectors are: a = [ 0 0 0 ] ; b= [2 1 1] and the sample is c = [ 0.001 0.001 0.001], I would like to get 2 coefficients, according to which I will be able to decide that the 'a' vector is the better fit. The basket case is, I cannot use xcorr(a,c,0,'coeff') function or corrcoef, since a vector of zeros will not give me a correlation coefficient, but will present NaN result instead.
I will also mention that the two vectors and the sample are the outcome of robustfit function, so actually I can use the lines' coefficients rather than the actual point vectors and call them through the function, if you guys think it's easier/better.
What do I do?
Accepted Answer
More Answers (0)
Categories
Find more on Descriptive Statistics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!