# bug #57800: view command produces different results in MATLAB and Octave

 Submitted by: SCI9 Submitted on: Wed 12 Feb 2020 03:50:58 PM UTC Category: Plotting Severity: 3 - Normal Priority: 5 - Normal Item Group: Matlab Compatibility Status: Fixed Assigned to: None Originator Name: Open/Closed: Closed Release: dev Operating System: Any

You are not logged in

## Discussion

Sun 16 Feb 2020 11:56:56 PM UTC, comment #3:

I overhauled the view function in this changeset: https://hg.savannah.gnu.org/hgweb/octave/rev/11072ea6a16c.  This included a fix for this bug report which will become available in the 6.1 release of Octave.

Rik <rik5>
Thu 13 Feb 2020 01:54:19 AM UTC, comment #2:

The issue is how to handle the conversion from a point (X,Y,Z) to an azimuth, elevation pair.  Matlab converts

view (0, 0, 1) -> az = 0, el = 90

while Octave converts this to

view (0, 0, 1) -> az = 90, el = 90

A point on the Z-axis (x = 0, y = 0) does not specify any particular azimuth when converted to spherical coordinates.  The software just needs to pick a value and it appears Matlab is using one convention and Octave another.

Working out the rules for Matlab would be useful.

Rik <rik5>
Wed 12 Feb 2020 04:18:03 PM UTC, comment #1:

I can reproduce on Octave 4.4.1 and 5.2 on macOS.

If you throw in an `xlabel('X Axis')` it clarifies things: Looks to me like the X and Y axes are getting swapped from where I would expect them to be.

Andrew Janke <apjanke>
Wed 12 Feb 2020 03:50:58 PM UTC, original submission:

The commands  `shading faceted` and `shading interp` produce different figures in MATLAB and Octave.

Consider this code:

[X, Y] = meshgrid(0:2, 0:2);
Z = magic(3);

figure;
colormap('jet');

subplot(1, 3 ,1);
imagesc(Z);
axis xy
yticklabels({'0', '1', '2'})
yticks(1:3)
xticklabels({'0', '1', '2'})
xticks(1:3)
title('imagesc(Z)');

subplot(1,3,2);
surf(X, Y, Z);
view([0,0,1]);
yticks(0:3)
xticks(0:3)

subplot(1,3,3);
surf(X, Y, Z);
view([0,0,1]);
yticks(0:3)
xticks(0:3)

This is the result in MATLAB:
https://i.stack.imgur.com/3o9gf.jpg

And the result generated by Octave:

MATLAB generates a correct figure. What is wrong with this Octave figure?

What is the reason we get two different outputs? Is it an issue with to the `view` command?

SCI9 <sci9>

## Attached Files

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

Comment:

Attached Files

## Dependencies

Depends on the following items: None found

Items that depend on this one: None found

Carbon-Copy List
• -email is unavailable- added by rik5 (Posted a comment)
• -email is unavailable- added by apjanke (Posted a comment)
• -email is unavailable- added by sci9 (Submitted the item)
•

Do you think this task is very important?
This task has 0 encouragements so far.

Only project members can vote.