Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Group info
Members: 34
Language: English
Group categories: Not categorized
More group info »
Recent pages and files
3). Draw    

Some Frequently Used Functions and Statements

1.1).       Figure   

Create figure graphics object, Figure objects are the individual windows on the screen in which MATLAB displays graphical output.

1.2).       Axis

Axis scaling and appearance

1.3).       Grid on / grid off

Grid lines for 2-D and 3-D plots

1.4).       Legend

Graph legend for lines and patches

1.5).       Text

Create text object in current axes

1.6).       Title

Add title to current axes

1.7).       xlabel, ylabel, zlabel

Label x-, y-, and z-axis

1.8).       grid on / grid off

Grid lines for 2-D and 3-D plot

Notice: You can set grid line width with the axes ‘LineWidth’ property.

1.9).       subplot 

Create axes in tiled positions.

1.10).    plot / plot3              

line plot, See ‘LineSpec’ in MATLAB help for a list of line style, marker, and color specifiers.

[e.g.]

plot(X1,Y1,LineSpec,X2,Y2, LineSpec)

1.11).    ezplot / ezplot3

Easy-to-use function plotter, it is especially useful for draw latent function.

[e.g.]

Figure(‘Name’, ‘ezplot example’);

fh = @(x,y) sqrt( x.^2 + y.^2);

h = ezplot( fh );

set( h, 'Color', 'black' );      % to set the color for ezplot, You can also try set( h, 'LineStyle', ':' ),                                   set( h, 'LineWidth' ,2 ) and set( h, 'Marker', 's' );  

hold on;

rdata = rand(100, 2);

plot( rdata( :, 1 ), rdata( :, 2 ), ‘r*’ );

grid on;

hold off;

1.12).    scatter / scatter3 / gscatter

Scatter plot.

[e.g.]

scatter(data(:,1), data(:,2), 10, data(:,end));

scatter3( data(:,1), data(:,2), data(:,4), 10, data(:,end) );

gscatter(data(:,1), data(:,2), data(:,end))

Notice: the 3rd parameter of scatter assigns the color for every scatter point; gscatter’s 3rd is the group parameter which point out which group every point belongs to. Points in different groups display in different color.

1.13).    plotmatrix / gplotmatrix

Scatter plot matrix.

[e.g.]

plotmatrix(data);

gplotmatrix( data(:, 1:end-1), data(:, 1:end-1), data(:, end) );

Notice: the 3rd parameter of gplotmatrix indicate which group every point belongs to.

1.14).    bar / barh / bar3 / bar3h

Draw two or three dimensional vertical and horizontal bar charts.

1.15).    hist

Histogram plot.

1.16).    surf / surfc

3-D shaded surface plot

1.17).    errorbar

Plot error bars along curve

[e.g.]

X = 0:pi/10:pi;

Y = sin(X);

E = std(Y)*ones(size(X));

errorbar(X, Y, E)

1.18).    getframe / addframe / movie / avifile / movie2avi

Play recorded movie frames

[e.g.]

Z = peaks; surf(Z);

axis tight

set(gca,'nextplot','replacechildren');

% Record the movie

for j = 1:20

    surf(sin(2*pi*j/20)*Z,Z)

    F(j) = getframe;

end

% Play the movie twenty times

movie(F,20);

%save the movie as an AVI file

movie2avi(F,’c://sample.avi’);

1.19).    boxplot

Box plots of data sample.

[e.g.]

boxplot(data(:,1),data(:,2),'notch','on','label',{'Column 1','Column 2'});

1.20).    treefit / treedisp / treeprune / treeplot

treefit: fit tree-based model for classification or regression

treeprune: produce sequence of sub-trees by pruning

treedisp: show classification or regression tree graphically. This function can also illustrate of tree pruning.

treeplot: plot picture of tree. I think it is not powerful enough for our project of decision tree.

[e.g.]

load fisheriris;

t = treefit(meas, species);

treedisp(t, 'names', {'SL' 'SW' 'PL' 'PW'})

Notice: t is a MATLAB struct. When you do the decision tree project, you can display the tree by invoking the function of treedisp. Since the input of treedisp is a struct, you need to convert your decision tree result to the struct. For more information, you can run treefit(data(:, 1:end-1), data(:,end)) to get an instance of struct so that you can see the details of the struct.

Version: 
Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google