On Saturday 24 January 2009 22:23:45 Ivan Pulido wrote: > Hey, I have a quick question, sorry if it's to "noob", but Im really new to > GSL and I've checked the manual and couldnt find the answer. > > What I want to do is reading a plain text file with data in the format > > x1 y1 > > x2 y2 > > ... and such > > So my doubt is how to read the first colum (xdata) and save it to a vector > xdata[] and the same with the second column and ydata[]. Is there a way to > do this with gsl_vector_fscanf function? I'd appreciate some help on this, > or at least some hints on what should I look for, thanks in advance.
It's not because you use GSL that you're forbidden to use just C :)
With x and y are pointers to a gsl_vector, one can use:
FILE * input = fopen("filename", "r");
int i = 0; while (fscanf (input, "%lf%lf", x->data+i, y->data+i) != EOF) ++i;
I assume you know the length of the vectors, in which case you could
use a for loop of course.
grtz
Steven
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Help-gsl mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-gsl
