Click here to Skip to main content
15,939,065 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi I'v been looking thrue the hole internet for a solution of interpolating a datatable but can't find a good answer.

I have a datatable with about 10 columns(double). The first column index in the data table is the x axel. and the rest needs to be interpolated to a new x. Some of the columns are empty.

Please give me input how to solve this in good way.

I have tried to convert the table to an array first and then back again but it will be tricky when some of the columns are empty and the code doesn't look good in my opinion.

What I have tried:

public void Interpolate(List<double> NewList, DataTable OldTable)
        {
            DataTable tempTable = OldTable.Clone();
            double[] newX = NewList.ToArray();
            
//Please give me some advice

            }
Posted
Updated 5-Feb-22 5:52am
Comments
Richard Deeming 4-Feb-22 9:17am    
You probably can't find an answer because nobody knows what you mean by "interpolating" a database.

Click the green "Improve question" link and update your question to include a clear and precise description of what you are trying to do, what you have tried, and where you are stuck.

For database questions, include the structure of the relevant tables, sample input data, and the expected output.

1 solution

You need at least one record / row that doesn't have "empty columns".

That row and the "x" (x1) is then your base.

"Interpolation" implies finding the value between two other values; however, since the columns are a funtion of x (I assume), you use x1 relative to x2 (for which column values are wanted) as a multiplier: e.g. x2 / x1 * each column.

If the column values are not "dependent on x", then this doesn't work.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900