Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mathematical type question

Status
Not open for further replies.

snt

MIS
Jun 19, 2000
104
US
I will try to explain as best as I can.

I am graphing data acquired from an external instrument.
There is a transition in the instrument which is causing a "step" in the data. I need to apply a formula to "smooth" out the data.
I need to take the last 5 data points before the transition (284-288) and get the average of those points. Then get the average of the first 3 data point after the transition (289-291). Then I need to average those 2 averages and mutliply it to 312 points after the transition. My problem is that I am not sure how to write this in code. Any help is greatly appreciated.

SNT
 
A couple of questions.

As the data is being read, what type of structure (array?) is the data being read into?

How are you detecting a transition step?

What do you mean by mutliply it to 312 points after the transition?

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein


 
Just to add to Cajun's questions, how are you graphing it? Are you using single points or drawing a line from the previous point? Anything is possible, the problem is I only have one lifetime.
[cheers]
 
1 - The data is being read into an array.
2 - The step can be seen graphically and it can be seen in text. ie. excel, notepad, etc...
3 - There are 312 points after the transition. For the graph not to have a step, the final average will need to be applied to each point after the transition. ex. If the final average equals 2, data points 289-600 need to multiplied by 2.
I hope I explained ok.

SNT
 
I'll take a shot at this, but this is based on a couple of assumptions:

1) The array has been completed populated with data points
2) The transition point is known

If either of these two assumptions are invalid, we may go back to the drawing board.

but here goes

dim total as single
dim ave1 as single
dim ave2 as single
dim finalave as single
dim i as integer
dim ptcount

total = 0
ptcount = 0
for i = 1 to 5
if (lbound(dataarray) >= tran_point - i) then
total = total + dataarray(tran_point - i)
ptcount = ptcount + 1
end If
next i
ave1 = total / ptcount

total = 0
ptcount = 0
for i = 1 to 3
if (ubound(dataarray) <= tran_point + i) then
total = total + dataarray(tran_point + i)
ptcount = ptcount + 1
end if
next i
ave2 = total / ptcount

finalave = (ave1 + ave2) / 2

for i = tran_point + 1 to ubound(dataarray)
dataarray(i) = dataarray(i) * finelave
next i
Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein


 
What type of data are you graphing, ie what instrument is generating the data (digital multi-meter, PLC, rangefinder, etc.)?

Does the graph have to be plotted in real-time?

Can you apply some curve fitting algorithm or do you have to use the approach you outlined? You might want to try and interpolate points so that the curve will look smoother.

Would you be able to post some of the data?
Troy Williams B.Eng.
fenris@hotmail.com

 
Sorry I got pulled away to a different project.

CajunCenturion,
I won't be able try your solution for a few days. I will get back to you with my results when I can.
Thank you for the help.

fenris,
The instrument being used is a proprietary instrument that measures spectra of materials.
The data does have to be plotted in real time. I cannot apply a curve fit because this would alter the data.

An example of the data can be see here:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top