octave-bug-tracker
[Top][All Lists]

## [Octave-bug-tracker] [bug #39370] contourc adds duplicates to the start

 From: Nicholas Jankowski Subject: [Octave-bug-tracker] [bug #39370] contourc adds duplicates to the start and end of the 1st level Date: Mon, 25 Jul 2022 10:11:15 -0400 (EDT)

```Follow-up Comment #8, bug #39370 (project octave):

looking at this a bit, it seems that octave is just pushing out the same
output that comes from contour, while matlab truncates the additional points:

Octave 8.0.0:

>> x = 0:2;
>> y = x;
>> z = x' * y;
>> a = contourc (x, y, z, 2:3)
a =

2.0000   1.0000   1.0000   2.0000   2.0000   3.0000   1.5000   2.0000
4.0000   2.0000   2.0000   1.0000   1.0000   2.0000   2.0000   1.5000

>> b = contour (x, y, z, 2:3)
b =

2.0000   1.0000   1.0000   2.0000   2.0000   3.0000   1.5000   2.0000
4.0000   2.0000   2.0000   1.0000   1.0000   2.0000   2.0000   1.5000

whereas with matlab:

>> x = 0:2;
y = x;
z = x' * y;
c = contourc (x, y, z, 2:3)
c =
2.0000    1.0000    2.0000    3.0000    1.5000    2.0000
2.0000    2.0000    1.0000    2.0000    2.0000    1.5000
>> b = contour (x, y, z, 2:3)
b =
Columns 1 through 7
2.0000    1.0000    1.0000    2.0000    2.0000    3.0000    1.5000
4.0000    2.0000    2.0000    1.0000    1.0000    2.0000    2.0000
Column 8
2.0000
1.5000

so i don't think the existance of the duplication is necessarily a bug.  the
fact that the duplication isn't pared down in contourc might be.

currently the matlab help for contourc states:

The matrix returned by contourc might be inconsistent with the results from
the contour, contourf, and contour3 functions. To get the matrix used by one
of those functions, call that function with an output argument.
https://www.mathworks.com/help/matlab/ref/contourc.html

whereas if you find some old documentation you'll find statements like:

Description
contourc calculates the contour matrix C used by the M-file contour to draw
actual contour plots.
...
http://www.math.clemson.edu/~warner/M860/Matlab/contour.html

None of that explains WHY contour in both programs, and originally both
contourc's produce the duplicate points, but at least it seems it was
historically consistent. at some point between the 1994 docs linked above and
this 2013 report, mathworks decided contourc should produce a non-duplicative
set. if it's simple and consistent, it may not take much to have the contourc
m-file just clip out those values.

_______________________________________________________

<https://savannah.gnu.org/bugs/?39370>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/

```