Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.graphics.apps.gnuplot > #194
| From | Carlos <carlosa.rega@gmail.com> |
|---|---|
| Newsgroups | comp.graphics.apps.gnuplot |
| Subject | Average and others over columns |
| Date | 2011-03-30 09:05 -0700 |
| Organization | http://groups.google.com |
| Message-ID | <afa31837-b776-4cfc-adb3-bfcfb927565d@n10g2000yqf.googlegroups.com> (permalink) |
Hi
First of all, thank you very much to everyone that contribute/have
contributed to gnuplot for such a great tool. I have been using it for
over 15 year now, and it is still the best tool there is.
Now I think I can contribute something back, if people are interested.
I have been playing with the idea of adding some functions that
produce averages, standard deviations, max, min etc of ranges, ie
something like:
plot 'file.csv' u 1:(average($2:$5))
would plot the average of columns 2 through 5, etc.
Would people be interested in such a feature?
If so, I have got some way into implementing it, though I think I need
some help on how to generate the correct action table. At the moment I
have gone for the average function taking a string argument, and then
parsing the range separately, to avoid having to change how the using
statements are parsed (the ':' would have to be interpreted
differently depending on where it is found and I don't want my change
to be too wide ranging).
I have now two issues:
* the functions that exist at the moment take a fixed number of
arguments (one from what I can see), but I need to pass an array, and
the value struct does not provide for it, so I suggest to add a field
to the v union to contain an array with the values to average over, so
it would look something like:
typedef struct value {
enum DATA_TYPES type;
union {
int int_val;
struct cmplx cmplx_val;
char *string_val;
double *col_values;
} v;
} t_value;
and the DATA_TYPES enum to look like:
enum DATA_TYPES {
INTGR=1,
CMPLX,
STRING,
COLUMN_RANGE
};
so that the receiving function can check whether the argument contains
the right data.
is this change reasonable?
* the second problem is where in the code is the actual value of the
column put into a.v.cmplx_val? I can follow the code up to where the
action table for the expression is generated, but I am having trouble
unraveling where I should create the array and feed it into the action
table (I haven't done any complex C programing for a ver long time),
anyone could point me in the right direction?
Best regards
Carlos
Back to comp.graphics.apps.gnuplot | Previous | Next | Find similar
Average and others over columns Carlos <carlosa.rega@gmail.com> - 2011-03-30 09:05 -0700
csiph-web