straight line graph, really straight line..

G

Guest

Hello, i am trying to add a trendline to graph which has 4 points and is
supposed to be producing a straight line (but does not always), so due to
these slight variations, the formula that i get from the trendline is not
always correct. i was wondering if there is a way to get a straight trendline
no matter the values are slightly a bit off, by just ignoring the ones which
dont fall under the "straight line category" ?? for instance, if the 3rd
value is slightly off, then ignoring just the 3rd??

if there is a way to do it through vba, and if you could show me a very
small example of the syntax or the code, or if it could be done in excel
itself, would be a great help as i am hoping to get my course work right..lol
 
M

Maistrye

Jason said:
Hello, i am trying to add a trendline to graph which has 4 points an
is
supposed to be producing a straight line (but does not always), so du
to
these slight variations, the formula that i get from the trendline i
not
always correct. i was wondering if there is a way to get a straigh
trendline
no matter the values are slightly a bit off, by just ignoring the one
which
dont fall under the "straight line category" ?? for instance, if th
3rd
value is slightly off, then ignoring just the 3rd??

if there is a way to do it through vba, and if you could show me
very
small example of the syntax or the code, or if it could be done i
excel
itself, would be a great help as i am hoping to get my course wor
right..lol

A fairly simplistic way would be to calculate the slopes between al
sets of two points, then take the most common slope. Using this slope
you'll need to find a suitable point on the line to get the equation o
the line you're looking for.

General Pseudocode:

For i = 1 to NumberOfPoints
For j = i+1 to NumberOfPoints
x = slope between i and j
Increase the count for slope x - some collection or other should d
this for you.
Next j
Next i

Go through your counts of slopes and determine the most common.

Find a point on the line.

Go through all the points to determine which points are on the line.

(Sorry, not 100% familiar with VB to the point where I could type ou
the actual code for you.)

Scot
 
G

Guest

Hey, you have given me the idea and the code, thats more than enough for me
to tweak the knobs. if it doesnt work, i will bother you again after
searching the net. :), thanks very much..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top