User:Eml4500.fisher/HW1)

-pg 17 Graphics Hardcopy

To obtain a hardcopy of the current graphic the command print is used. This command will send the image to the default printer using predefined settings. These settings can be changed by using the printopt command.

The command print followed by a name can be used to print and save the grapic. If the name following the print command does not include a post script the appropriate post script will be assigned to the file. Several graphics can be saved to a single file and printed using the print -append filename command. If the append command is not used on an existing file, the existing file will be overwritten with the new graphic.

Graphics other then the current graphic can be printed and saved by use of the command print -deps -graphic filename. An example of this command is print -deps -f4 Lulz. The previous command will save figure 4 in file Lulz.eps.

3-D Line Plots

Matlab will produce plots in 3 dimensions using the command plot3. If the X, Y and Z coordinates are the desired coordinates the the command would be as follows, plot3(X,Y,Z). An example of a plot using this command is as follows, t=.01:.01:20*pi; x=cos(t); y=sin(t); z=t.^3; plot3(x,y,z), which creates the following helix: - - - - The axis limits can then be determined using the axis command.

3-D Mesh and Surface Plots.

Mesh plots can be created using the meshcommand. For example the command mesh(x) will create a mesh plot of the predetermined matrix x. Surface plots are created in a similar fashion using the surf command. Just as before the surf(x) command will create a surface plot of the predetermined matrix x.

In order to draw a graph of a function z=f(x,y) it is important to first define xx and yy. These will give partitions of the sides of the rectangle in which the graph is on. Using the command [x,y] = meshgrid(xx,yy); a matrix x and a matrix y are created. Each row of matrix x is equal to xx and it has a column length equal to the length of yy. Each column of matrix y is equal to yy. For example if one wanted to graph z=e-x 2-y2 over the square [-2,2]X[-2,2] the code would be as follows: [x,y]=meshgrid(-2:.2:2,-2:.2:2); z=exp(-x.^2-y.^2); mesh(z) Just as before the last command can be either mesh or surf depending on if a mesh or a surface plot is desired. Also, just as before the command axis will describe the axis limits.

The shading of the surface plot can be changed with the shading command. The three choices are shading faceted, shading interp, or shading flat. It is important to not that the shading command should be entered after the surf command and only the shading faceted command leaves the superimposed mesh lines.