Bird
0
0

What will the following MATLAB code display?

medium📝 Predict Output Q5 of 15
MATLAB - 3D Plotting and Visualization
What will the following MATLAB code display?
X = linspace(0,1,5); Y = X.^2; Z = sqrt(X); plot3(X, Y, Z, 'g--');
AA solid green 2D line ignoring Z
BA green dashed 3D line through points with X from 0 to 1
CAn error due to invalid element-wise operations
DA blue dotted 3D line
Step-by-Step Solution
Solution:
  1. Step 1: Analyze vector creation

    X is 5 points from 0 to 1, Y is X squared element-wise, Z is square root of X element-wise.
  2. Step 2: Understand plot3 style

    'g--' means green dashed line connecting the 3D points.
  3. Final Answer:

    A green dashed 3D line through points with X from 0 to 1 -> Option B
  4. Quick Check:

    Element-wise ops + 'g--' = green dashed 3D line [OK]
Quick Trick: Use .^ and sqrt for element-wise vector math [OK]
Common Mistakes:
  • Forgetting dot before ^ for element-wise power
  • Confusing line styles
  • Assuming 2D plot instead of 3D

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More MATLAB Quizzes