MATLAB Lecture 9 School of Mathematical Sciences Xiamen University http://gdjpkc.xmu.edu.cn 10. Print graph. set(gcf, PaperPositionMode', auto) ☆ Line plots of3- D Data The 3-D analog of the plot function is plot. If x, y, and z are three vectors of the same length, plot(x,y, z) generates a line in 3-D through the points whose coordinates are the elements of x,y, and z and then produces a 2-D projection of that line on the screen >>t=0:pi/50:10*pi; >>t20*pipi/50:20*pi, > plot(sin(t), cos(t), t, *-b') >>comet3(sin(t), cos(t), t) > axis square, grid on Ds Figure B以些 :邮口 If the arguments to plot3 are matrices of the same size, MATLAB plots lines obtained from the columns of x.y and Z >>[X,Y=meshgrid([-2: 0. 1: 2); >>X+-2:0.1:2J:Y=-20.12] >>Z=X.+exp(-X2-Y.2) >>Z=X.exp(-X2-Y.2) > plot(X,Y,z) > plot(X,Y,Z) > grid on > grid on F Ba司 il. Edit Yiw Insert Toalr Desktop tinder Help (费回长口国m口 ≥日我回日目口MATLAB Lecture 9 School of Mathematical Sciences Xiamen University http://gdjpkc.xmu.edu.cn Lec92 10. Print graph. set(gcf,'PaperPositionMode','auto') print dps2 ² Line Plots of 3D Data The 3D analog of the plot function is plot3. If x, y, and z are three vectors of the same length, plot3(x,y,z) generates a line in 3D through the points whose coordinates are the elements of x, y, and z and then produces a 2D projection of that line on the screen. >> t = 0:pi/50:10*pi; >> t=20*pi:pi/50:20*pi; >> plot3(sin(t),cos(t),t, '*b') >> comet3(sin(t), cos(t),t) >> axis square; grid on ¸ Plotting Matrix Data If the arguments to plot3 are matrices of the same size, MATLAB plots lines obtained from the columns of X, Y, and Z. >> [X,Y] = meshgrid([2:0.1:2]); >> X=[2:0.1:2]; Y=[2:0.1:2]; >> Z = X.*exp(X.^2Y.^2); >> Z = X.*exp(X.^2Y.^2); >> plot3(X,Y,Z) >> plot3(X,Y,Z) >> grid on >> grid on