Chapter 5 Commands | CMPSC 200 - Programming for Engineers with MATLAB, Quizzes of Computer Science

Commands, Functions and Special Characters that pertain to plotting Class: CMPSC 200 - Programming for Engineers with MATLAB; Subject: Computer Science; University: Penn State - Main Campus;

Typology: Quizzes

Pre 2010

Uploaded on 12/12/2009

ultimatefrisbie1
ultimatefrisbie1 🇺🇸

1 document

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
TERM 1
Plot(x,y)
DEFINITION 1
Creates a linear x-y plot. Can also be used as
plot(x1,y1,x2,y2) to plot two sets of data Can also plot
arrays. ex. plot(x,[y1;y2...]) to plot multiple sets of data Can
also plot complex numbers
TERM 2
title('string')
DEFINITION 2
adds 'string' as a title to a plot
TERM 3
1 xlabel('string') 2 ylabel('string')
DEFINITION 3
1 adds 'string' as a label to the x-axis on a plot 2 adds
'string' as a label to the y-axis on a plot
TERM 4
1 grid 2 grid on 3 grid off
DEFINITION 4
1 adds a grid to graph, or toggles grid on or off 2 turns the
grid on 3 turns the grid off
TERM 5
pause
DEFINITION 5
pauses the execution of the program, allowing the user to
view the graph
pf3
pf4
pf5

Partial preview of the text

Download Chapter 5 Commands | CMPSC 200 - Programming for Engineers with MATLAB and more Quizzes Computer Science in PDF only on Docsity!

Plot(x,y)

Creates a linear x-y plot. Can also be used as plot(x1,y1,x2,y2) to plot two sets of data Can also plot arrays. ex. plot(x,[y1;y2...]) to plot multiple sets of data Can also plot complex numbers TERM 2

title('string')

DEFINITION 2 adds 'string' as a title to a plot TERM 3

1 xlabel('string') 2 ylabel('string')

DEFINITION 3 1 adds 'string' as a label to the x-axis on a plot 2 adds 'string' as a label to the y-axis on a plot TERM 4

1 grid 2 grid on 3 grid off

DEFINITION 4 1 adds a grid to graph, or toggles grid on or off 2 turns the grid on 3 turns the grid off TERM 5

pause

DEFINITION 5 pauses the execution of the program, allowing the user to view the graph

1 figure 2 figure(#)

1 determines which figure will be used(changes current figure) 2 Makes # the current figure TERM 7

1 hold 2 hold on 3 hold off

DEFINITION 7 1 freezes the current plot, so that an additional plot can be overlaid(toggles hold on/off) 2 holds the plot 3 releases the plot TERM 8

Plot(x,y,'--og')

DEFINITION 8 syntax for plotting x-y graph with certain line, mark and color options ex. a dashed(--) green line(g) with the points circled(o). Line Types: - solid : dotted -. dash-dot -- dashed TERM 9

axis axis(vector)

DEFINITION 9 when this command is used without inputs, it freezes the axis at the current configurations. Executing the function a second time returns axis control to MATLAB. The input to this command must be a four element vector that specifies the minimum and maximum values for both the x- and y-axes ex: [xmin,xmax,ymin,ymax] TERM 10

legend('string1','string2',etc)

DEFINITION 10 allows you to add a legend to your graph. the legend shows a sample of the line and lists the string you have specified.

1semilogx(x,y) 2semilogy(x,y)

1generates an x-y plot using a logarithmic scale for x 2generates an x-y plot using a logarithmic scale for y TERM 17

loglog(x,y)

DEFINITION 17 generates a plot of the vectors x and y using a logarithmic scale for both x and y TERM 18

hist(x) hist(x,n)

DEFINITION 18 creates a histogram graph for data in x when n is specified creates histogram with n number of "bins" TERM 19

plotyy

DEFINITION 19 generates a graph with two y-axes, the one on the left for the first set of ordered pairs, and the one on the right for the second set of ordered pairs. TERM 20

1 fplot(fhandle,bounds) 2

fplot('string',bounds)

DEFINITION 20 1 allows you to plot a function without defining arrays of corresponding x and y values 2 same but you can define 'string' as the function ex. 'sin(x)'

plot3(x,y,z)

creates a 3 dimensional line plot TERM 22

comet3(x,y,z)

DEFINITION 22 generates an animated version of plot TERM 23

mexh(z) mexh(x,y,z)

DEFINITION 23 creates a meshed surface plot TERM 24

surf(z) surf(x,y,z)

DEFINITION 24 creates a surface plot, similar to mesh function TERM 25

shading

interp

DEFINITION 25 interpolates between the colors used to illustrate surface plots