User:Eml4500.f08.bottle.loschak/HW1

Output Format
Using the format command the user can change the format of the displayed output. Here are some choices with data from the help command:

Hardcopy
In order to obtain a hardcopy one's work, the easiest command to use is diary filename. This will begin writing everything that appears on the screen until the command diary off is entered. The command diary on will resume writing. This file can be viewed later and printed. The diary command will not record graphics.

Graphics
A user can plot different types of graphs using the primary commands plot, plot3, mesh, and surf. The plot command is used for creating linear x-y plots, such as a sine curve or an exponential. To graph a sine wave from -pi to pi a user can enter the following command: x = -pi:.01:pi; y = sin(x); plot(x,y) It is possible to plot multiple curves on the same graph by adding more arguments into the parentheses, like so: x = -pi:.01:pi; y1 = sin(x); y2=cos(x); plot(x,y1,x,y2) Changing the color and linetype of the lines being plotted is also possible by adding arguments into the plot command. For example: x = -pi:.01:pi; y1 = sin(x); y2=cos(x); plot(x,y1,'b--',x,y2,'y:') Will produce a sine curve with a blue dashed line and a cosine curve with a yellow dotted line. Graphs can be labeled by the following commands: The hold command will allow the next plot to be superimposed on top of the old plot until the command "hold off" is used. To save a graph the command print filename is useful. It will automatically save as a *.ps PostScript file unless a file extension is specified. Adding to the command, print -append filename, one can add multiple images to the same image file. A 3-D line plot can be displayed with the command plot3(x,y,z) by including 3 vectors of the same size. A mesh plot or a surface plot can be displayed with the commands mesh(x) or surf(x). Shading on surfaces can be controlled with the "shading" command. The commands "set(1)" and "gca,set(ans)" can be used to control properties of graphs.

Sparse Matrix Computations
In the event that a user must perform many calculations with matrices containing a large amount of zeros, the "sparse" command can be used to ignore the zeros and save time and storage space. With matrix B containing a large amount of zeros, matrix S can save space by entering the command S = sparse(B). The process can be reversed by entering the command B=full(S). The function spdiags can create a sparse banded matrix by specifying diagonals.