A. W. Dunstan
2010-08-10 15:06:41 UTC
I've got some data in the form of (x, y) pairs that I want to plot as a 3-
dimensional scatter plot. The (x, y) pairs aren't unique and I'd like to
show the count (how many times a given pair occurs) as the Z coordinate.
To do the counting, in C++ I'd use a std::pair<double, double> as an index
into a std::map; in AWK I could so something similar using it's associative
arrays. How do I do this in Octave?
I could write the data out & do some post-processing in AWK or C++ and then
feed it into gnuplot but I was trying to find a way of doing the whole thing
in Octave.
Typical data points look something like:
-6.61 -3.95
-6.61 -3.95
-6.61 -3.95
-4.412 -3.56
1.2 -2.1
-4.412 -3.56
0.2 1.1
0.2 1.1
These would become:
-6.61 -3.95 3
-4.412 -3.56 2
1.2 -2.1 1
0.2 1.1 2
If I could use an array as an index into another array this would be easy,
but I can't. At least, I haven't been able to thus far, but that may be due
more to my ignorance than anything else.
I think my problem is that I don't know what to search for. I've tried
'octave non-scalar array index', "octave map', 'octave dictionary' and
similar things but didn't get very far. Any pointers on what I should look
for, or where? Am I taking the wrong approach? Thanks!
--
Al Dunstan, Software Engineer
OptiMetrics, Inc.
3115 Professional Drive
Ann Arbor, MI 48104-5131
"There are two ways of constructing a software design. One way is to make
it so simple that there are obviously no deficiencies. And the other way
is to make it so complicated that there are no obvious deficiencies."
- C. A. R. Hoare
dimensional scatter plot. The (x, y) pairs aren't unique and I'd like to
show the count (how many times a given pair occurs) as the Z coordinate.
To do the counting, in C++ I'd use a std::pair<double, double> as an index
into a std::map; in AWK I could so something similar using it's associative
arrays. How do I do this in Octave?
I could write the data out & do some post-processing in AWK or C++ and then
feed it into gnuplot but I was trying to find a way of doing the whole thing
in Octave.
Typical data points look something like:
-6.61 -3.95
-6.61 -3.95
-6.61 -3.95
-4.412 -3.56
1.2 -2.1
-4.412 -3.56
0.2 1.1
0.2 1.1
These would become:
-6.61 -3.95 3
-4.412 -3.56 2
1.2 -2.1 1
0.2 1.1 2
If I could use an array as an index into another array this would be easy,
but I can't. At least, I haven't been able to thus far, but that may be due
more to my ignorance than anything else.
I think my problem is that I don't know what to search for. I've tried
'octave non-scalar array index', "octave map', 'octave dictionary' and
similar things but didn't get very far. Any pointers on what I should look
for, or where? Am I taking the wrong approach? Thanks!
--
Al Dunstan, Software Engineer
OptiMetrics, Inc.
3115 Professional Drive
Ann Arbor, MI 48104-5131
"There are two ways of constructing a software design. One way is to make
it so simple that there are obviously no deficiencies. And the other way
is to make it so complicated that there are no obvious deficiencies."
- C. A. R. Hoare