Writing a program for background correction of experimental data

Hello everyone,

I happen to need to write a program that imports a x,y-Graph, fits an exponetial function to said graph, substracts it and stores the result in a new file.

So far, I was able to figure out that this would require to define a 2D array and fill it from a textfile.

My first problem is this: I cannot know how many datapoints my graph has. It may be a few hundreds, but just as well it can be a few tens of thousands. How can I define an array that will have a size fitting to the number of dataponits I might have?

I then believe I need fill the array using a while loop and somethig like this

while (!myfile.eof())
{
getline (myfile, filename [a][b],' ');
}

Is that correct, or is there something missing?

The next part is where I really didn`t find anything useful about: I know I can create an exponential function via the "type exp (type x)" command, but I didn`t find a way to fit it to a given set of values. Any help or pointers you might provide would be much appreciated.

The rest doesn`t strike me as too difficult, I believe I have found something on calculating with arrays in Ivor Hortons`s "Beginning Visual C++", so I guess I can manage the substraction. For writing the result in a file, I have seen some examples of the ofstream command, which will probably do.

I would very much appreciate any form of aid you might give me, including pointers to where I can find the answers to my questions.
My first problem is this: I cannot know how many datapoints my graph has. It may be a few hundreds, but just as well it can be a few tens of thousands. How can I define an array that will have a size fitting to the number of dataponits I might have?

A std:vector will help, since its size can be dynamically changed.

Aceix.
How about using existing applications, like gnuplot for some steps?
Topic archived. No new replies allowed.