view() not returning [az, el] ??

5 次查看(过去 30 天)
Ken
Ken 2024-4-26
编辑: Paul 2024-4-27
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 个评论
Walter Roberson
Walter Roberson 2024-4-27
Based on the doc, the result of a single-output call to view is undefined (but the most likely result is the azimuth)
Paul
Paul 2024-4-27
编辑:Paul 2024-4-27
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?

请先登录,再进行评论。

回答(1 个)

Adam Danz
Adam Danz 2024-4-26
编辑:Adam Danz 2024-4-26
The azimuth and elevation outputs are returned as two separate outputs.
f = figure('visible','off');
ax = gca(f);
[az, el] = view(gca)
az = 0
el = 90
You discovered a little easter egg 😏
When only 1 output is requested, view returns a view matrix in a left handed coordinate system.

类别

Help CenterFile Exchange 中查找有关 Programming Utilities 的更多信息

产品


版本

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by