Complete the code to plot a 3D line using plot3.
x = 1:5; y = 2:6; z = 3:7; plot3(x, y, [1]);
The plot3 function requires x, y, and z coordinates. Here, z is the third coordinate vector.
Complete the code to add grid lines to the 3D plot.
x = 0:0.5:2*pi; y = sin(x); z = cos(x); plot3(x, y, z); grid [1];
Using grid on turns on the grid lines in the plot, making it easier to see the 3D structure.
Fix the error in the code to plot a red dashed 3D line.
x = 0:1:10; y = x.^2; z = sqrt(x); plot3(x, y, z, '[1]');
The color and line style are specified as a string. 'r--' means a red dashed line.
Fill both blanks to create a 3D plot with markers and a green solid line.
x = 1:4; y = [2, 4, 6, 8]; z = [1, 3, 5, 7]; plot3(x, y, z, '[1][2]');
The marker 'o' adds circles at data points, and 'g' sets the line color to green. The line style defaults to solid if not specified.
Fill all three blanks to create a 3D plot with blue dash-dot line, and line width 2.
x = linspace(0, 2*pi, 10); y = sin(x); z = cos(x); h = plot3(x, y, z, '[1][2]'); h.LineWidth = [3];
'b' sets the color blue, '-.' sets dash-dot line style, and LineWidth = 2 makes the line thicker. Markers are not included here.