view() not returning [az, el] ??
1 view (last 30 days)
Show older comments
According to this documentation, I believe that the view function should be returning a two element vector [azimuth, elevation]. However, I observed that it actually returns a 4 x 4 projection matrix. But it won't take one! So what do I need to do to get something out of view that it will accept later, to restore the viewpoint?
Here is a command window view of actions taken at a couple of breakpoints in my program:
(Breakpoint, when graph is showing a 3D plot)
K>> a=view(graph)
a =
0.7934 -0.6088 0 -0.0923
0.3044 0.3967 0.8660 -0.7835
0.5272 0.6871 -0.5000 8.3031
0 0 0 1.0000
(Another breakpoint, when graph is showing a 2D plot)
K>> a=view(graph)
a =
1.0000 0 0 -0.5000
0 1.0000 0 -0.5000
0 0 -1.0000 9.1603
0 0 0 1.0000
K>> view(graph, a)
Error using view>ViewCore
Argument must be scalar, or two-vector.
Error in view (line 93)
ViewCore(hAxes, viewArgs{:});
14 Comments
Walter Roberson
on 27 Apr 2024
Based on the doc, the result of a single-output call to view is undefined (but the most likely result is the azimuth)
Paul
on 27 Apr 2024
Edited: Paul
on 27 Apr 2024
Why is it undefined?
According to Ignore Function Outputs, "... you can request only the first N outputs of a function (where N is less than or equal to the number of possible outputs) and ignore any remaining outputs." followed by examples to show exactly what that clause means.
The doc page for the very example on that doc page, which is fileparts, only shows a use with three outputs. Yet calling FILEPARTS with one output is not defined?
Answers (1)
Adam Danz
on 26 Apr 2024
Edited: Adam Danz
on 26 Apr 2024
The azimuth and elevation outputs are returned as two separate outputs.
f = figure('visible','off');
ax = gca(f);
[az, el] = view(gca)
You discovered a little easter egg 😏
When only 1 output is requested, view returns a view matrix in a left handed coordinate system.
0 Comments
See Also
Categories
Find more on Function Creation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!