[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #39243] patch - matlab compatibility - changin
From: |
Nicholas Jankowski |
Subject: |
[Octave-bug-tracker] [bug #39243] patch - matlab compatibility - changing xdata length produces dimension warning |
Date: |
Mon, 29 Nov 2021 19:23:05 -0500 (EST) |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36 |
Follow-up Comment #19, bug #39243 (project octave):
I've seen a number of cases where Matlab allows you to change/set a property
after the fact that you wouldn't be able to set initially. In some cases it
only catches incompatibilities later (in this case, maybe something like a
call to 'draw').
In Octave, to trim both xdata and ydata via set, you have to do them one at a
time, and you get the intermediate warning. In Matlab, if you trim xdata or
ydata, it automatically trims the other to match:
octave:
>> xdata = cosd (0:60:360);
>> ydata = sind (0:60:360);
>> h = patch (xdata, ydata, 'b', 'marker', 's'); %% draws hexagon
>> get(h, 'xdata'),get(h, 'ydata')
ans =
1.0000
0.5000
-0.5000
-1.0000
-0.5000
0.5000
1.0000
ans =
0
0.8660
0.8660
0
-0.8660
-0.8660
0
>> set (h, 'xdata', xdata(1:end-3));
>> warning: opengl_renderer: x/y/zdata must have the same dimensions. Not
rendering.
get(h, 'xdata'),get(h, 'ydata')
ans =
1.0000 0.5000 -0.5000 -1.0000
ans =
0
0.8660
0.8660
0
-0.8660
-0.8660
0
>> set (h, 'ydata', ydata(1:end-3));
>> get(h, 'xdata'),get(h, 'ydata')
ans =
1.0000 0.5000 -0.5000 -1.0000
ans =
0 0.8660 0.8660 0
matlab:
>> xdata = cosd (0:60:360);
>> ydata = sind (0:60:360);
>> h = patch (xdata, ydata, 'b', 'marker', 's'); %% draws hexagon
>> get(h,'xdata'), get(h, 'ydata')
ans =
1.0000
0.5000
-0.5000
-1.0000
-0.5000
0.5000
1.0000
ans =
0
0.8660
0.8660
0
-0.8660
-0.8660
0
>> set (h, 'xdata', xdata(1:end-3));
>> get(h,'xdata'), get(h, 'ydata')
ans =
1.0000
0.5000
-0.5000
-1.0000
ans =
0
0.8660
0.8660
0
(same effect if you change ydata first. matlab trims xdata to match.)
i couldn't get the repeated warning to duplicate, but it did mess with the
following >> prompt, apparently putting it up on the line with the warning.
Also note the orientation difference. Apparently both store column vectors
even if row vectors are supplied, but while matlab's set forces row vectors,
octave's set keeps a row vector. and apparently this will trigger the same
warning, even if numel(xdata)=numel(ydata): (see below)
>> xdata = cosd (0:60:360);
>> ydata = sind (0:60:360);
>> h = patch (xdata, ydata, 'b', 'marker', 's'); %% draws hexagon
>> get(h, 'xdata'),get(h, 'ydata')
ans =
1.0000
0.5000
-0.5000
-1.0000
-0.5000
0.5000
1.0000
ans =
0
0.8660
0.8660
0
-0.8660
-0.8660
0
>> set (h, 'xdata', xdata(1:end));
>> warning: opengl_renderer: x/y/zdata must have the same dimensions. Not
rendering.
get(h, 'xdata'),get(h, 'ydata')
ans =
1.0000 0.5000 -0.5000 -1.0000 -0.5000 0.5000 1.0000
ans =
0
0.8660
0.8660
0
-0.8660
-0.8660
0
vs matlab:
>> xdata = cosd (0:60:360);
>> ydata = sind (0:60:360);
>> h = patch (xdata, ydata, 'b', 'marker', 's'); %% draws hexagon
>> get(h,'xdata'), get(h, 'ydata')
ans =
1.0000
0.5000
-0.5000
-1.0000
-0.5000
0.5000
1.0000
ans =
0
0.8660
0.8660
0
-0.8660
-0.8660
0
>> xdata(1:end)
ans =
1.0000 0.5000 -0.5000 -1.0000 -0.5000 0.5000 1.0000
>> set (h, 'xdata', xdata(1:end));
>> get(h,'xdata'), get(h, 'ydata')
ans =
1.0000
0.5000
-0.5000
-1.0000
-0.5000
0.5000
1.0000
ans =
0
0.8660
0.8660
0
-0.8660
-0.8660
0
summary:
1 - there's some inconsistency in how octave stores the data (set not forcing
column vectors)
2 - in matlab editing either xdata or ydata (or zdata?) automatically trims
the other(s) to match. that seems to be a more significant compatibility
error.
I'm also thinking this probably warrants closing this bug report and opening a
new one.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?39243>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #39243] patch - matlab compatibility - changing xdata length produces dimension warning, Nicholas Jankowski, 2021/11/29
- [Octave-bug-tracker] [bug #39243] patch - matlab compatibility - changing xdata length produces dimension warning, Pantxo Diribarne, 2021/11/29
- [Octave-bug-tracker] [bug #39243] patch - matlab compatibility - changing xdata length produces dimension warning,
Nicholas Jankowski <=
- [Octave-bug-tracker] [bug #39243] patch {x, y, z, c}data properties are not independent, Nicholas Jankowski, 2021/11/30
- [Octave-bug-tracker] [bug #39243] patch {x, y, z, c}data properties are not independent, Nicholas Jankowski, 2021/11/30