MATLAB5.1 5.2 5.3 5.4 5.5 5.6 5.7 MATLAB 5.8
5.1 ezplot f, x, y
ezplot(f)f = f(x)-2*pi
5.1 ezplot('x^3 + 2*x^2 - 3*x + 5 - y^2')f = inline('cos(x)+2*sin(x)'); ezplot(f)ezplot('sin(3*t)*cos(t)','sin(3*t)*sin(t)',[0,pi]) ezplot('t*cos(t)','t*sin(t)',[0,4*pi])ezplot('x^2 + y^2 - 1',[-1.25,1.25]); axis equalezplot('cos(x)', [0, pi])
5.1 fplot fplot('function',limits)fplot plots a function between specified limits. The function must be of the form y = f(x), where x is a vector whose range specifies the limits, and y is a vector the same size as x and contains the function's value at the points in x (see the first example). If the function returns more than one value for a given x, then y is a matrix whose columns contain each component of f(x) (see the second example).fplot('tanh',[-2 2])Create an M-file, myfun, that returns a two column matrix:function Y = myfun(x)Y(:,1) = 200*sin(x(:))./x(:);Y(:,2) = x(:).^2;Plot the function with the statement: fplot('myfun',[-20 20]fplot('[tan(x),sin(x),cos(x)]',2*pi*[-1 1 -1 1])
5.2 MATLAB plot3 help specgraph
bar3 comet3pie3quiver3ezplot3stem3
5.2 x, y, z=sphere(n) x, y, z=cylinder(R, n) x, y, z=ellipsoid(xc, yc, zc, xr, yr, zr, n)subplot(221),sphere(3),title('N=3')subplot(222),sphere(6),title('N=6')subplot(223),sphere(20),title('N=20')subplot(224),sphere(50),title('N=50')
5.2 x, y, z=cylinder(R, n) R R=[5 0]subplot(221),cylinder(R, 3),title('N=3')subplot(222), cylinder(R,6),title('N=6')subplot(223), cylinder(R),title('N=20')subplot(224), cylinder(R,50),title('N=50')
5.2 x, y, z=ellipsoid(xc, yc, zc, xr, yr, zr, n)xc, yc, zc, xr, yr, zrsubplot(221), ellipsoid(0,0,0,1,2,3, 3),title('N=3')subplot(222), ellipsoid(0,0,0,1,2,3, 6),title('N=6')subplot(223), ellipsoid(0,0,0,1,2,3),title('N=20')subplot(224), ellipsoid(0,0,0,1,2,3, 50),title('N=50')
5.2 mesh(x, y, z, c) x, y x y z , c x, y meshgrid
surf(x, y, z, c)
hidden on hidden off
colorbar
5.2 [x,y]=meshgrid(-3:0.1:3,-2:0.1:2);z=(x.^2-2*x).*exp(-x.^2-y.^2-x.*y); mesh(x,y,z)
5.2 >> [x,y]=meshgrid(-3:0.1:3,-2:0.1:2);>> z=(x.^2-2*x).*exp(-x.^2-y.^2-x.*y); surf(x,y,z) colorbar, hidden on, hidden off
5.2 shading faceted, flat interp light( Position, [x, y, z]) surf surfl colormap(MAP) MAP nX3 R, G, B hot, cool, copper, pink, gray, bone, prism, flag NaN
5.2 [x,y]=meshgrid(-3:0.1:3,-2:0.1:2);z=(x.^2-2*x).*exp(-x.^2-y.^2-x.*y); surfl(x,y,z)light('pos',[-3 2 1.5])shading flat;
5.2 [x,y]=meshgrid(-3:0.1:3,-2:0.1:2);z=(x.^2-2*x).*exp(-x.^2-y.^2-x.*y); surfl(x,y,z)light('pos',[-3 2 1.5])shading flat; colormap(hot);
5.2 contour(x, y, z, n) contour3(x, y, z, n)[x,y]=meshgrid(-3:0.1:3,-2:0.1:2);z=(x.^2-2*x).*exp(-x.^2-y.^2-x.*y); surfl(x,y,z)subplot(121); contour(x, y, z, 50), subplot(122), contour3(x, y, z, 50);
5.2 waterfall(x, y, z )[x,y]=meshgrid(-3:0.1:3,-2:0.1:2);z=(x.^2-2*x).*exp(-x.^2-y.^2-x.*y); waterfall(x, y, z)
5.3 MATLAB set, get MATLAB
5.3 set(H, PropertyName, PropertyValue, )PropertyValue = get(H, PropertyName) h=figure; get(h); MATLAB h=axes; get(h); MATLAB t=0:0.1:2*pi; y=sin(t); h=plot(t,y); get(h) MATLAB set(h) h
5.3
ChildernParentCreateFcnDeleteFcnInterruptibleonoffSelectedonoffTagTypeUserDataVisibleonoff
5.3 Xlabel, X. YZ
BoxonoffColorOrdernX3GridLineStyle:NextPlotreplace, addTitle title XLabelX xlabel XDirXnormal, revXGridXonoffXLimXxmin, xmaxXScaleXlinear, logXTickXonoff
5.3
Color1 X 3 FontAnglenormal, italicFontNameTimes New Roman, Courier FontSizeFontWeightlight, normal, demi, boldHorizontalAlignmentleft, center, rightFontUnitspoints, inches, centmeters, pixels, normalizedRotationEditingon, offStringInterpreterTEXtex, none
5.3
Color1 X 3 LineStyle plot LineWidth 0.5Marker plot MarkerSize 6XDataX
5.3 >> clf; t=0:0.4:2*pi; hc=plot(t, sin(t), '-pentagram');>> ht=gtext(' This is the original text');>> y1=get(hc, 'YData');>> set(hc, 'MarkerSize', 20, 'LineStyle','-.','Color','k','YDaa', 2*y1);>> set(hc, 'MarkerSize', 20, 'LineStyle','-.','Color','k','YData', 2*y1);>> set(ht, 'String', 'Udated Text', 'FontSize', 20, 'Rotation', 10);
5.4 GUI EDIT protedit
5.4
5.5
5.5 MATLAB view view(az, el) view([az, el]) view(T)az, el= view, az, el=view(3), T=view[x,y]=meshgrid(-3:0.1:3,-2:0.1:2); z=(x.^2-2*x).*exp(-x.^2-y.^2-x.*y); subplot(121),surf(x,y,z);[a,b]=view; subplot(122),surf(x,y,z);view(-a,b);
5.5 MATLAB [x,y]=meshgrid(-3:0.1:3,-2:0.1:2); z=(x.^2-2*x).*exp(-x.^2-y.^2-x.*y);subplot(221),surf(x,y,z),shading flat, axis([-3 3 -2 2 -0.7 1.5]);view(0,90),title('view(0,90)')subplot(222),mesh(x,y,z),axis([-3 3 -2 2 -0.7 1.5]);view(90,0),title('view(90,0)')subplot(223),mesh(x,y,z),axis([-3 3 -2 2 -0.7 1.5]);view(0,0),title('view(0,0)')subplot(224),mesh(x,y,z),axis([-3 3 -2 2 -0.7 1.5]);title('normal viewpoint')
5.5 surf [x,y]=meshgrid(-3:0.1:3,-2:0.1:2); z=(x.^2-2*x).*exp(-x.^2-y.^2-x.*y);subplot(221),surf(x,y,z),shading interp, axis([-3 3 -2 2 -0.7 1.5]);view(0,90),title('view(0,90)')subplot(222),surf(x,y,z),shading interp,axis([-3 3 -2 2 -0.7 1.5]);view(90,0),title('view(90,0)')subplot(223),surf(x,y,z), shading interp,axis([-3 3 -2 2 -0.7 1.5]);view(0,0),title('view(0,0)')subplot(224),surf(x,y,z), shading interp,axis([-3 3 -2 2 -0.7 1.5]);title('normal viewpoint')
5.6 MATLAB MATLAB bmp, jpg, hdf, pcx, png, tiff, xwd
imreadimwriteimfinfoimage
5.6 MATLAB >> img=imread('greens.jpg');>> whos Name Size Bytes Class img 300x500x3 450000 uint8 arrayGrand total is 450000 elements using 450000 bytes>> imwrite(img, 'test.bmp','bmp');>> image(img)
5.7 MATLAB Edit Copy print -device -options filename -device -dwin -dwinc -dps PostScript-dpsc PostScript; -deps EPS -depsc EPS -dhpg1HP-djpegJPEG-dtiffTIFF -dmeta -dbitmap>> print -deps aaa