Matlab - Getting start, страница 8
Описание файла
PDF-файл из архива "Matlab - Getting start", который расположен в категории "". Всё это находится в предмете "цифровая обработка сигналов (цос)" из 8 семестр, которые можно найти в файловом архиве МГТУ им. Н.Э.Баумана. Не смотря на прямую связь этого архива с МГТУ им. Н.Э.Баумана, его также можно найти и в других разделах. Архив можно найти в разделе "книги и методические указания", в предмете "цифровая обработка сигналов" в общих файлах.
Просмотр PDF-файла онлайн
Текст 8 страницы из PDF
The Property Editorprovides access to many properties of the root, figure, axes, line, light, patch,image, surfaces rectangle, and text objects. For example, using the PropertyEditor, you can change the thickness of a line, add titles and axes labels, addlights, and perform many other plot editing tasks.This figure shows the components of the Property Editor interface.Use these buttons to move back and forth among the graphics objects you have edited.Use the navigation bar to selectthe object you want to edit.Click on a tab to view a groupof properties.Click here to view a list ofvalues for this field.Check this checkbox to see theeffect of your changes as youmake them..Click OK to apply your changesand dismiss the Property Editor.Click Cancel to dismiss the Property Editorwithout applying your changes.4-16Click Apply to apply your changeswithout dismissing the Property Editor.Click Help to get information aboutparticular properties.Editing PlotsStarting the Property EditorYou start the Property Editor by double-clicking on an object in a graph, suchas a line, or by right-clicking on an object and selecting the Properties optionfrom the object’s context menu.You can also start the Property Editor by selecting either the FigureProperties, Axes Properties, or Current Object Properties from the figurewindow Edit menu.
These options automatically enable plot editing mode, if itis not already enabled.Once you start the Property Editor, keep it open throughout an editing session.It provides access to all the objects in the graph. If you click on another objectin the graph, the Property Editor displays the set of panels associated with thatobject type. You can also use the Property Editor’s navigation bar to select anobject in the graph to edit.4-174GraphicsMesh and Surface PlotsMATLAB defines a surface by the z-coordinates of points above a grid in the x-yplane, using straight lines to connect adjacent points.
The mesh and surfplotting functions display surfaces in three dimensions. mesh produceswireframe surfaces that color only the lines connecting the defining points.surf displays both the connecting lines and the faces of the surface in color.Visualizing Functions of Two VariablesTo display a function of two variables, z = f (x,y):• Generate X and Y matrices consisting of repeated rows and columns,respectively, over the domain of the function.• Use X and Y to evaluate and graph the function.The meshgrid function transforms the domain specified by a single vector ortwo vectors x and y into matrices X and Y for use in evaluating functions of twovariables. The rows of X are copies of the vector x and the columns of Y arecopies of the vector y.Example – Graphing the sinc FunctionThis example evaluates and graphs the two-dimensional sinc function, sin(r)/r,between the x and y directions.
R is the distance from origin, which is at thecenter of the matrix. Adding eps (a MATLAB command that returns thesmallest floating-point number on your system) avoids the indeterminate 0/0at the origin.[X,Y] = meshgrid(-8:.5:8);R = sqrt(X.^2 + Y.^2) + eps;Z = sin(R)./R;mesh(X,Y,Z,'EdgeColor','black')4-18Mesh and Surface Plots10.50−0.510510500−5−5−10−10By default, MATLAB colors the mesh using the current colormap.
However,this example uses a single-colored mesh by specifying the EdgeColor surfaceproperty. See the surface reference page for a list of all surface properties.You can create a transparent mesh by disabling hidden line removal.hidden offSee the hidden reference page for more information on this option.Example – Colored Surface PlotsA surface plot is similar to a mesh plot except the rectangular faces of thesurface are colored. The color of the faces is determined by the values of Z andthe colormap (a colormap is an ordered list of colors).
These statements graphthe sinc function as a surface plot, select a colormap, and add a color bar toshow the mapping of data to color.surf(X,Y,Z)colormap hsvcolorbar4-194Graphics10.810.60.50.400.2−0.5105100500−5−5−10−0.2−10See the colormap reference page for information on colormaps.Surface Plots with LightingLighting is the technique of illuminating an object with a directional lightsource.
In certain cases, this technique can make subtle differences in surfaceshape easier to see. Lighting can also be used to add realism tothree-dimensional graphs.This example uses the same surface as the previous examples, but colors it redand removes the mesh lines. A light object is then added to the left of the“camera” (that is the location in space from where you are viewing the surface).4-20Mesh and Surface PlotsAfter adding the light and setting the lighting method to phong, use the viewcommand to change the view point so you are looking at the surface from adifferent point in space (an azimuth of -15 and an elevation of 65 degrees).Finally, zoom in on the surface using the toolbar zoom mode.surf(X,Y,Z,'FaceColor','red','EdgeColor','none');camlight left; lighting phongview(-15,65)4-214GraphicsImagesTwo-dimensional arrays can be displayed as images, where the array elementsdetermine brightness or color of the images.
For example, the statementsload durerwhosNameXcaptionmapSizeBytesClass648x5092x28128x326386561123072double arraychar arraydouble arrayload the file durer.mat, adding three variables to the workspace. The matrix Xis a 648-by-509 matrix and map is a 128-by-3 matrix that is the colormap for thisimage.Note MAT-files, such as durer.mat, are binary files that can be created on oneplatform and later read by MATLAB on a different platform.The elements of X are integers between 1 and 128, which serve as indices intothe colormap, map. Thenimage(X)colormap(map)axis imagereproduces Dürer’s etching shown at the beginning of this book.
A highresolution scan of the magic square in the upper right corner is available inanother file. Typeload detailand then use the uparrow key on your keyboard to reexecute the image,colormap, and axis commands. The statementcolormap(hot)adds some twentieth century colorization to the sixteenth century etching. Thefunction hot generates a colormap containing shades of reds, oranges, and4-22Imagesyellows. Typically a given image matrix has a specific colormap associated withit.
See the colormap reference page for a list of other predefined colormaps.4-234GraphicsPrinting GraphicsYou can print a MATLAB figure directly on a printer connected to yourcomputer or you can export the figure to one of the standard graphic fileformats supported by MATLAB. There are two ways to print and exportfigures:• Using the Print option under the File menu• Using the print commandPrinting from the MenuThere are four menu options under the File menu that pertain to printing:• The Page Setup option displays a dialog box that enables you to adjustcharacteristics of the figure on the printed page.• The Print Setup option displays a dialog box that sets printing defaults, butdoes not actually print the figure.• The Print Preview option enables you to view the figure the way it will lookon the printed page.• The Print option displays a dialog box that lets you select standard printingoptions and print the figure.Generally, use Print Preview to determine whether the printed output is whatyou want.
If not, use the Page Setup dialog box to change the output settings.Select the Page Setup dialog box Help button to display information on how toset up the page.Exporting Figure to Graphics FilesThe Export option under the File menu enables you to export the figure to avariety of standard graphics file formats.Using the Print CommandThe print command provides more flexibility in the type of output sent to theprinter and allows you to control printing from M-files. The result can be sentdirectly to your default printer or stored in a specified file.
A wide variety ofoutput formats, including TIFF, JPEG, and PostScript, is available.For example, this statement saves the contents of the current figure window ascolor Encapsulated Level 2 PostScript in the file called magicsquare.eps. It4-24Printing Graphicsalso includes a TIFF preview, which enables most word processors to displaythe pictureprint -depsc2 -tiff magicsquare.epsTo save the same figure as a TIFF file with a resolution of 200 dpi, use thecommandprint -dtiff -r200 magicsquare.tiffIf you type print on the command line,printMATLAB prints the current figure on your default printer.4-254GraphicsHandle GraphicsWhen you use a plotting command, MATLAB creates the graph using variousgraphics objects, such as lines, text, and surfaces (see “Graphics Objects” onpage 4-26 for a complete list).