Challenge - 5 Problems
View Angle Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of the view angle after this code?
Consider the following MATLAB code that sets the view angle of a 3D plot. What will be the azimuth and elevation angles after running this code?
MATLAB
figure; plot3(1:10, rand(1,10), rand(1,10)); view(45, 30); current_view = view;
Attempts:
2 left
💡 Hint
The view function in MATLAB takes azimuth first, then elevation.
✗ Incorrect
The view function sets the azimuth and elevation angles in that order. So view(45,30) sets azimuth to 45 degrees and elevation to 30 degrees.
❓ Predict Output
intermediate2:00remaining
What happens if you call view with a single argument?
What is the effect of calling view(2) in MATLAB on a 3D plot?
MATLAB
figure; plot3(1:10, rand(1,10), rand(1,10)); view(2); current_view = view;
Attempts:
2 left
💡 Hint
Calling view with a single number sets a predefined view.
✗ Incorrect
In MATLAB, view(2) sets the view to the top view of the XY plane, which corresponds to azimuth 0 and elevation 90.
❓ Predict Output
advanced2:00remaining
What is the output of this code changing view angles dynamically?
What will be the final azimuth and elevation angles after running this MATLAB code?
MATLAB
figure; plot3(1:10, rand(1,10), rand(1,10)); for az = 0:45:180 view(az, 45); end final_view = view;
Attempts:
2 left
💡 Hint
The loop sets the view multiple times, the last one is the final.
✗ Incorrect
The loop increments azimuth from 0 to 180 in steps of 45, setting elevation to 45 each time. The final call is view(180,45).
❓ Predict Output
advanced2:00remaining
What error does this code raise?
What error will this MATLAB code produce?
MATLAB
figure; plot3(1:10, rand(1,10), rand(1,10)); view('top');
Attempts:
2 left
💡 Hint
The view function expects numeric inputs or specific strings like '2D' or '3D'.
✗ Incorrect
The string 'top' is not a valid input for view in MATLAB, so it raises an invalid input argument error.
🧠 Conceptual
expert3:00remaining
How to programmatically rotate a 3D plot by 90 degrees around the vertical axis?
Which MATLAB code snippet correctly rotates an existing 3D plot by 90 degrees around the vertical (z) axis from its current view?
Attempts:
2 left
💡 Hint
Azimuth controls rotation around the vertical axis.
✗ Incorrect
Adding 90 degrees to the azimuth angle rotates the plot 90 degrees around the vertical axis while keeping elevation unchanged.