毕业设计——人脸检测——003 学习别人代码

代码学习

今天学习http://blog.csdn.net/lyqmath/article/details/6139043 lyqmath的代码


我将其代码复制到一个txt文档,然后署名‘test face’,并更改后缀名为‘.m’。使用matlab运行,报错“Undefined function or method 'test' for input arguments of type 'char'”,看到就傻眼了。Google了一下,看到帖子http://hi.baidu.com/liuzhiliangliang/blog/item/cdb1be189658d0bf4aedbcb2.html 看到重命名文件,我想可能是我的M文件名出错了,然后修改为‘test2’,之后运行正常。


ndims -Number of array dimensions 阵列维数的尺寸(简体:数组,繁体:阵列)

Syntax 语法

n = ndims(A)

Description 说明

n = ndims(A) returns the number of dimensions in the array A. The number of dimensions in an array is always greater than or equal to 2. Trailing singleton dimensions are ignored. A singleton dimension is any dimension for which size(A,dim) = 1.

“n = ndims(A)”返回在阵列A中维数的数目。在一个阵列中的维数的数目总是大于或等于2。“Trailing singleton dimensions ”这个维数被忽略(不清楚双引号里面的是什么意思,直译为:拖尾的单例维数)。单例维数(singleton dimension)是“size(A,dim) = 1”这样的维数。(关于size会在后面介绍)

Algorithms 算法

ndims(x) is length(size(x)).

 

size -Array dimensions 阵列维数;阵列尺寸(阵列各维的尺寸)

Syntax

d= size(X)

[m,n] = size(X)

m = size(X,dim)

[d1,d2,d3,...,dn] = size(X),

Description

d = size(X) returns the sizes of each dimension of array X in a vector d with ndims(X) elements. If X is a scalar, which MATLAB software regards as a 1-by-1 array, size(X) returns the vector [11]. 一个矢量d包含“ndims(X)”个元素,返回阵列X的各维的大小到d。如果X是一个标量,则MATLAB软件视其一个1*1的阵列,size(X)返回矢量[1 1]。

[m,n] = size(X) returns the size of matrix X in separate variables m and n. 返回有单独变量m和n的矩阵X的大小。

m = size(X,dim) returns the size of the dimension of X specified by scalar dim. 返回指定标量dim的X的维数大小

[d1,d2,d3,...,dn] = size(X), for n > 1, returns the sizes of the dimensions of the array X in the variables d1,d2,d3,...,dn, provided the number of output arguments n equals ndims(X). If n does not equal ndims(X), the following exceptions hold:

返回阵列X的维数大小到变量d1,d2,d3,...,dn中,提供的输出参数n等于ndims(X)。如果n不等于ndims(X),异常处理如下:

n < ndims(X)

di equals the size of the ith dimension of X for 1<=i<n , but dn equals the product of the sizes of the remaining dimensions of X, that is, dimensions n through ndims(X)

di等于X第i个维数的大小,但是dn等于X剩余维数的大小,也就是,维数n到ndims(X)  (待查:感觉翻译得很不准确)

n > ndims(X)

size returns ones in the "extra" variables, that is, those corresponding to ndims(X)+1 through n.

size返回到一个临时变量中,也就是,那些从n相对应到ndims(X)+1

 

Note   For a Java array, size returns the length of the Java array as the number of rows. The number of columns is always 1. For a Java array of arrays, the result describes only the top level array.

Examples 例子

Example 1 例子1

The size of the second dimension of rand(2,3,4) is 3.    ‘rand(2,3,4)’的第二维的大小是3。

m = size(rand(2,3,4),2)
 
m =
     3

Here the size is output as a single vector.   这里的大小是用一个单一向量输出

d = size(rand(2,3,4))
 
d =
     2     3     4

Here the size of each dimension is assigned to a separate variable. 这里的每个维数大小被分配给分开的变量。

[m,n,p] = size(rand(2,3,4))
m =
     2
 
n =
     3
 
p =
     4
Example 2

If X= ones(3,4,5), then    如果 X = ones(3,4,5)

[d1,d2,d3] = size(X)
 
d1 =       d2 =       d3 =
     3          4          5

But when the number of output variables is less than ndims(X):    但是当输出变量的大小小于 ndims(X)时

[d1,d2] = size(X)
 
d1 =       d2 =
     3          20

The "extra" dimensions are collapsed into a single product.    额外维数被收缩到一个单一结果

If n> ndims(X), the "extra" variables all represent singleton dimensions:    如果‘n> ndims(X)’,“额外的“变量均表现出单件模式的维度

[d1,d2,d3,d4,d5,d6] = size(X)
 
d1 =       d2 =       d3 =
     3          4          5
 
d4 =       d5 =       d6 =
     1          1          1

 

rgb2gray -Convert RGB image or colormap to grayscale  将RGB图像或色图转换为灰度图

Syntax

I = rgb2gray(RGB)

newmap = rgb2gray(map)

Description

I = rgb2gray(RGB) converts the truecolor image RGB to the grayscale intensity image I. rgb2gray converts RGB images to grayscale by eliminating the hue and saturation information while retaining the luminance.

转换真色图像RGB为灰度, 亮度图I。rgb2gray转换RGB图为灰度图去除色调和色饱和度信息同时保留亮度。

newmap = rgb2gray(map) returns a grayscale colormap equivalent to map.

Note   A grayscale image is also called a gray-scale, gray scale, or gray-level image.

Class Support    类型支持

If the input is an RGB image, it can be of class uint8, uint16, single, or double. The output image I is of the same class as the input image. If the input isa colormap, the input and output colormaps are both of class double.

Examples

Convert an RGB image to a grayscale image.

I = imread('board.tif');

J = rgb2gray(I);

figure, imshow(I),figure, imshow(J);

Convert the colormap to a grayscale colormap.

[X,map] =imread('trees.tif');

gmap = rgb2gray(map);

figure, imshow(X,map),figure, imshow(X,gmap);

Algorithms

rgb2gray converts RGB values to grayscale values by forming aweighted sum of the RG, and B components:

0.2989 * R + 0.5870 * G +0.1140 * B

Note that these are the same weights used by the rgb2ntsc function to compute the Y component.

 

im2bw -Convert image to binary image,based on threshold   基于阀值的图像转换为二进制图像

Syntax

BW= im2bw(I, level)

BW = im2bw(X, map, level)

BW = im2bw(RGB, level)

Description

BW = im2bw(I, level) converts the grayscale image I to a binary image. The output image BW replaces all pixels in the input image with luminance greater than level with the value 1 (white) and replaces all other pixels with the value 0 (black). Specify level in the range [0,1]. This range is relative to the signal levels possible for the image's class. Therefore, a level value of 0.5 is midway between black and white, regardless of class. To compute the level argument, you can use the function graythresh.If you do not specify levelim2bw uses the value 0.5.

BW = im2bw(X, map, level) converts the indexed image X with colormap map to a binary image.

BW = im2bw(RGB, level) converts the truecolor image RGB to a binary image.

If theinput image is not a grayscale image, im2bw converts the input image to grayscale, and then converts thisgrayscale image to binary by thresholding.

Class Support

Theinput image can be of class uint8uint16singleint16, or double, and must benonsparse. The output image BW is of class logicalIand X must be 2-D. RGB images are M-by-N-by-3.

 

graythresh -Global image threshold using Otsu's method  全局图阀值使用Otsu's方法

Syntax

level= graythresh(I)

[level EM] = graythresh(I)

Description

level = graythresh(I) computes a global threshold (level) that can beused to convert an intensity image to a binary image with im2bw.level is a normalized intensity value that lies in therange [0, 1].

The graythresh function uses Otsu's method, which chooses thethreshold to minimize the intraclass variance of the black and white pixels.

Multidimensionalarrays are converted automatically to 2-D arrays using reshape. The graythresh function ignores any nonzero imaginary part of I.

[level EM] = graythresh(I) returns the effectiveness metric, EM, as the second output argument. Theeffectiveness metric is a value in the range [0 1] that indicates theeffectiveness of the thresholding of the input image. The lower bound isattainable only by images having a single gray level, and the upper bound isattainable only by two-valued images.

Class Support

Theinput image I can be of class uint8uint16int16single,or double and it must be nonsparse. The return value level is a double scalar. The effectiveness metric EM is a double scalar.

Examples

I = imread('coins.png');
level = graythresh(I);
BW = im2bw(I,level);
imshow(BW)

References

[1] Otsu, N., "A Threshold Selection Methodfrom Gray-Level Histograms," IEEE Transactions on Systems, Man, and Cybernetics,Vol. 9, No. 1, 1979, pp. 62-66.


figure -

Create figure graphics object

Syntax

figure
figure('PropertyName',propertyvalue,...)
figure(h)
h = figure(...)

Properties

For a list of properties, see Figure Properties.

Description

figure creates figure graphics objects. Figure objects are the individual windows on the screen in which the MATLAB software displays graphical output.

figure creates a new figure object using default property values. This automatically becomes the current figure and raises it above all other figures on the screen until a new figure is either created or called.

figure('PropertyName',propertyvalue,...) creates a new figure object using the values of the properties specified. For a description of the properties, see Figure Properties. MATLAB uses default values for any properties that you do not explicitly define as arguments.

figure(h) does one of two things, depending on whether or not a figure with handle h exists. If h is the handle to an existing figure,figure(h) makes the figure identified by h the current figure, makes it visible, and raises it above all other figures on the screen. The current figure is the target for graphics output. If h is not the handle to an existing figure, but is an integer, figure(h) creates a figure and assigns it the handle hfigure(h) where h is not the handle to a figure, and is not an integer, is an error.

h = figure(...) returns the handle to the figure object.


cat -Concatenate arrays along specified dimension

Syntax

C = cat(dim, A, B)
C = cat(dim, A1, A2, A3, A4, ...)

Description

C = cat(dim, A, B)concatenates the arrays A and B along array dimension dim.

C = cat(dim, A1, A2, A3, A4, ...)concatenates all the input arrays (A1A2A3A4, and so on) along array dimension dim.

For nonempty arrays, cat(2, A, B) is the same as [A, B], and cat(1, A, B) is the same as [A; B].

Tips

When used with comma-separated list syntax, cat(dim, C{:}) or cat(dim, C.field) is a convenient way to concatenate a cell or structure array containing numeric matrices into a single matrix.

For information on combining unlike integer types, integers with nonintegers, cell arrays with non-cell arrays, or empty matrices with other elements, see Combining Unlike Classes in the Programming Fundamentals documentation.

Examples

Given

A =               B =
     1     2                   5     6
     3     4                   7     8

concatenating along different dimensions produces

The commands

A = magic(3); B = pascal(3);
C = cat(4, A, B);

produce a 3-by-3-by-1-by-2 array.


hold -Retain current graph in figure

Syntax

hold on
hold off
hold all
hold
hold(axes_handle,...)

Description

The hold function determines whether new graphics objects are added to the graph or replace objects in the graph. hold toggles theNextPlot property between the add and replace states.

hold on retains the current plot and certain axes properties so that subsequent graphing commands add to the existing graph. If no current axes exist before you call hold on, MATLAB creates new axes and retains the default properties. However, some axes properties change to accommodate additional graphics objects. For example, the axes' limits increase when the data requires them to do so. hold onsets the NextPlot property of the current figure and axes to add.

hold off resets axes properties to their defaults before drawing new plots. hold off is the default. hold off sets the NextPlot property of the current axes to replace.

hold all holds the plot and the current line color and line style so that subsequent plotting commands do not reset the ColorOrder andLineStyleOrder property values to the beginning of the list. Plotting commands continue cycling through the predefined colors and linestyles from where the last plot stopped in the list.

hold toggles the hold state between adding to the graph and replacing the graph.

hold(axes_handle,...) applies the hold to the axes identified by the handle axes_handle. The hold function sets the NextPlot property of the current figure and the current axes. If several axes objects exist in a figure window, each axes has its own hold state. hold also creates an axes if one does not exist.

Test the hold state using the ishold function.


meshgrid -Rectangular grid in 2-D and 3-D space

Syntax

[X,Y] = meshgrid(xgv,ygv)
[X,Y,Z] = meshgrid(xgv,ygv,zgv)
[X,Y] = meshgrid(gv)
[X,Y,Z] = meshgrid(gv)

Description

[X,Y] = meshgrid(xgv,ygv) replicates the grid vectors xgv and ygv to produce a full grid. This grid is represented by the output coordinate arrays X and Y. The output coordinate arrays X and Y contain copies of the grid vectors xgv and ygv respectively. The sizes of the output arrays are determined by the length of the grid vectors. For grid vectors xgv and ygv of length M and N respectively, X and Y will have Nrows and M columns.

[X,Y,Z] = meshgrid(xgv,ygv,zgv) produces three-dimensional coordinate arrays. The output coordinate arrays XY, and Z contain copies of the grid vectors xgvygv, and zgv respectively. The sizes of the output arrays are determined by the length of the grid vectors. For grid vectors xgvygv, and zgv of length MN, and P respectively, XY, and Z will have N rows, M columns, and P pages.

[X,Y] = meshgrid(gv) is the same as [X,Y] = meshgrid(gv,gv). In other words, you can reuse the same grid vector in each respective dimension. The dimensionality of the output arrays is determined by the number of output arguments.

[X,Y,Z] = meshgrid(gv) is the same as [X,Y,Z] = meshgrid(gv,gv,gv). Again, the dimensionality of the output arrays is determined by the number of output arguments.

The output coordinate arrays are typically used to evaluate functions of two or three variables. They are also frequently used to create surface and volumetric plots.

Input Arguments

xgv,ygv,zgv

Grid vectors specifying a series of grid point coordinates in the xy and z directions, respectively.

gv

Generic grid vector specifying a series of point coordinates.

Output Arguments

X,Y,Z

Output arrays that specify the full grid.

Tips

The meshgrid function is similar to ndgrid, however meshgrid is restricted to 2-D and 3-D while ndgrid supports 1-D to N-D. The coordinates output by each function are the same, but the shape of the output arrays in the first two dimensions are different. For grid vectors x1gv,x2gv and x3gv of length MN and P respectively, meshgrid(x1gv, x2gv) will output arrays of size N-by-M while ndgrid(x1gv, x2gv) outputs arrays of size M-by-N. Similarly, meshgrid(x1gv, x2gv, x3gv) will output arrays of size N-by-M-by-P while ndgrid(x1gv, x2gv, x3gv) outputs arrays of size M-by-N-by-P. See Grid Representation in the MATLAB Mathematics documentation for more information.


round -Round to nearest integer

Syntax

Y = round(X)

Description

Y = round(X) rounds the elements of X to the nearest integers. Positive elements with a fractional part of 0.5 round up to the nearest positive integer. Negative elements with a fractional part of -0.5 round down to the nearest negative integer. For complex X, the imaginary and real parts are rounded independently.

Examples

a = [-1.9, -0.2, 3.4, 5.6, 7.0, 2.4+3.6i]

a =
  Columns 1 through 4 
  -1.9000            -0.2000             3.4000             5.6000 
  Columns 5 through 6 
   7.0000             2.4000 + 3.6000i

round(a)

ans =
  Columns 1 through 4 
  -2.0000                  0             3.0000             6.0000 
  Columns 5 through 6 
   7.0000             2.0000 + 4.0000i 

linspace -Generate linearly spaced vectors

Syntax

y = linspace(a,b)
y = linspace(a,b,n)

Description

The linspace function generates linearly spaced vectors. It is similar to the colon operator ":", but gives direct control over the number of points.

y = linspace(a,b) generates a row vector y of 100 points linearly spaced between and including a and b.

y = linspace(a,b,n) generates a row vector y of n points linearly spaced between and including a and b. For n < 2linspace returns b.

Examples

Create a vector of 100 linearly spaced numbers from 1 to 500:

A = linspace(1,500);

Create a vector of 12 linearly spaced numbers from 1 to 36:

A = linspace(1,36,12);

mesh -Mesh plot

Alternatives

To graph selected variables, use the Plot Selector  in the Workspace Browser, or use the Figure Palette Plot Catalog. Manipulate graphs in plot edit mode with the Property Editor. For details, see Plotting Tools — Interactive Plotting in the MATLAB Graphics documentation and Creating Graphics from the Workspace Browser in the MATLAB Desktop Tools documentation.

Syntax

mesh(X,Y,Z)
mesh(Z)
mesh(...,C)
mesh(...,'PropertyName',PropertyValue,...)
mesh(axes_handles,...)
h = mesh(...)

Description

mesh(X,Y,Z) draws a wireframe mesh with color determined by Z, so color is proportional to surface height. If X and Y are vectors,length(X) = n and length(Y) = m, where [m,n] = size(Z). In this case, (X(j)Y(i)Z(i,j)) are the intersections of the wireframe grid lines; X and Y correspond to the columns and rows of Z, respectively. If X and Y are matrices, (X(i,j)Y(i,j)Z(i,j)) are the intersections of the wireframe grid lines.

mesh(Z) draws a wireframe mesh using X = 1:n and Y = 1:m, where [m,n] = size(Z). The height, Z, is a single-valued function defined over a rectangular grid. Color is proportional to surface height.

mesh(...,C) draws a wireframe mesh with color determined by matrix C. MATLAB performs a linear transformation on the data in C to obtain colors from the current colormap. If XY, and Z are matrices, they must be the same size as C.

mesh(...,'PropertyName',PropertyValue,...) sets the value of the specified surface property. Multiple property values can be set with a single statement.

mesh(axes_handles,...) plots into the axes with handle axes_handle instead of the current axes (gca).

h = mesh(...) returns a handle to a Surfaceplot graphics object.

Tips

mesh does not accept complex inputs.

A mesh is drawn as a Surfaceplot graphics object with the viewpoint specified by view(3). The face color is the same as the background color (to simulate a wireframe with hidden-surface elimination), or none when drawing a standard see-through wireframe. The current colormap determines the edge color. The hidden command controls the simulation of hidden-surface elimination in the mesh, and theshading command controls the shading model.


zeros -Create array of all zeros

Syntax

B = zeros(n)
B = zeros(m,n)
B = zeros([m n])
B = zeros(m,n,p,...) 
B = zeros([m n p ...])
B = zeros(size(A))
Y = zeros
zeros(m, n,...,classname)
zeros([m,n,...],classname)

Description

B = zeros(n) returns an n-by-n matrix of zeros. An error message appears if n is not a scalar.

B = zeros(m,n) or B = zeros([m n]) returns an m-by-n matrix of zeros.

B = zeros(m,n,p,...) or B = zeros([m n p ...]) returns an m-by-n-by-p-by-... array of zeros.


floor -Round toward negative infinity

Syntax

B = floor(A)

Description

B = floor(A) rounds the elements of A to the nearest integers less than or equal to A. For complex A, the imaginary and real parts are rounded independently.


find -Find indices and values of nonzero elements

Syntax

ind = find(X)
ind = find(X, k)
ind = find(X, k, 'first')
ind = find(X, k, 'last')
[row,col] = find(X, ...)
[row,col,v] = find(X, ...)

Description

ind = find(X) locates all nonzero elements of array X, and returns the linear indices of those elements in vector ind. If X is a row vector, then ind is a row vector; otherwise, ind is a column vector. If X contains no nonzero elements or is an empty array, then ind is an empty array.

ind = find(X, k) or ind = find(X, k, 'first') returns at most the first k indices corresponding to the nonzero entries of Xk must be a positive integer, but it can be of any numeric data type.

ind = find(X, k, 'last') returns at most the last k indices corresponding to the nonzero entries of X.

[row,col] = find(X, ...) returns the row and column indices of the nonzero entries in the matrix X. This syntax is especially useful when working with sparse matrices. If X is an N-dimensional array with N > 2, col contains linear indices for the columns. For example, for a 5-by-7-by-3 array X with a nonzero element at X(4,2,3)find returns 4 in row and 16 in col. That is, (7 columns in page 1) + (7 columns in page 2) + (2 columns in page 3) = 16.

[row,col,v] = find(X, ...) returns a column or row vector v of the nonzero entries in X, as well as row and column indices. If X is a logical expression, then v is a logical array. Output v contains the non-zero elements of the logical array obtained by evaluating the expression X. For example,

A= magic(4)
A =
    16     2     3    13
     5    11    10     8
     9     7     6    12
     4    14    15     1

[r,c,v]= find(A>10);

r', c', v'
ans =
     1     2     4     4     1     3
ans =
     1     2     2     3     4     4
ans =
     1     1     1     1     1     1

Here the returned vector v is a logical array that contains the nonzero elements of N where

N=(A>10)

bwlabel -Label connected components in 2-D binary image

Syntax

L = bwlabel(BW, n)
[L, num] = bwlabel(BW, n)

Description

L = bwlabel(BW, n) returns a matrix L, of the same size as BW, containing labels for the connected objects in BW. The variable n can have a value of either 4 or 8, where 4 specifies 4-connected objects and 8 specifies 8-connected objects. If the argument is omitted, it defaults to 8.

The elements of L are integer values greater than or equal to 0. The pixels labeled 0 are the background. The pixels labeled 1 make up one object; the pixels labeled 2 make up a second object; and so on.

[L, num] = bwlabel(BW, n) returns in num the number of connected objects found in BW.

Tips

Using bwlabel, bwlabeln, bwconncomp, and regionprops

The functions bwlabelbwlabeln, and bwconncomp all compute connected components for binary images. bwconncomp replaces the use ofbwlabel and bwlabeln. It uses significantly less memory and is sometimes faster than the other functions.

  Input Dimension Output Form Memory Use Connectivity
bwlabel 2-D Double-precision label matrix High 4 or 8
bwlabeln N-D Double-precision label matrix High Any
bwconncomp N-D CC struct Low Any

To extract features from a binary image using regionprops with default connectivity, just pass BW directly into regionprops, i.e.,regionprops(BW).

To compute a label matrix having a more memory-efficient data type (e.g., uint8 versus double), use the labelmatrix function on the output of bwconncomp. For more information, see the reference page for each function.

Using find with bwlabel

You can use the MATLAB find function in conjunction with bwlabel to return vectors of indices for the pixels that make up a specific object. For example, to return the coordinates for the pixels in object 2, enter the following:

[r, c] = find(bwlabel(BW)==2)

You can display the output matrix as a pseudocolor indexed image. Each object appears in a different color, so the objects are easier to distinguish than in the original image. For more information, see label2rgb.

Class Support

BW can be logical or numeric, and it must be real, two-dimensional, and nonsparse. L is of class double.

Examples

Label components using 4-connected objects. Notice objects 2 and 3; with 8-connected labeling, bwlabel would consider these a single object rather than two separate objects.

BW = logical ([1     1     1     0     0     0     0     0
               1     1     1     0     1     1     0     0
               1     1     1     0     1     1     0     0
               1     1     1     0     0     0     1     0
               1     1     1     0     0     0     1     0
               1     1     1     0     0     0     1     0
               1     1     1     0     0     1     1     0
               1     1     1     0     0     0     0     0]);

L = bwlabel(BW,4)

L =

     1     1     1     0     0     0     0     0
     1     1     1     0     2     2     0     0
     1     1     1     0     2     2     0     0
     1     1     1     0     0     0     3     0
     1     1     1     0     0     0     3     0
     1     1     1     0     0     0     3     0
     1     1     1     0     0     3     3     0
     1     1     1     0     0     0     0     0

[r, c] = find(L==2);
rc = [r c]

rc =
 
     2     5
     3     5
     2     6
     3     6

Algorithms

bwlabel uses the general procedure outlined in reference [1], pp. 40-48:

  1. Run-length encode the input image.

  2. Scan the runs, assigning preliminary labels and recording label equivalences in a local equivalence table.

  3. Resolve the equivalence classes.

  4. Relabel the runs based on the resolved equivalence classes.

References

[1] Haralick, Robert M., and Linda G. Shapiro, Computer and Robot Vision, Volume I, Addison-Wesley, 1992, pp. 28-48.


regionprops -Measure properties of image regions

Syntax

STATS = regionprops(BW, properties)
STATS = regionprops(CC, properties)
STATS = regionprops(L, properties)
STATS = regionprops(..., I, properties)

Description

STATS = regionprops(BW, properties) measures a set of properties for each connected component (object) in the binary image, BW. The image BW is a logical array; it can have any dimension.

STATS = regionprops(CC, properties) measures a set of properties for each connected component (object) in CC, which is a structure returned by bwconncomp.

STATS = regionprops(L, properties) measures a set of properties for each labeled region in the label matrix L. Positive integer elements of L correspond to different regions. For example, the set of elements of L equal to 1 corresponds to region 1; the set of elements of Lequal to 2 corresponds to region 2; and so on.

STATS = regionprops(..., I, properties) measures a set of properties for each labeled region in the image I. The first input toregionprops—either BWCC, or L—identifies the regions in I. The sizes must match: size(I) must equal size(BW)CC.ImageSize, or size(L).

STATS is a structure array with length equal to the number of objects in BWCC.NumObjects, or max(L(:)). The fields of the structure array denote different properties for each region, as specified by properties.


rectangle -Create 2-D rectangle object

Syntax

rectangle
rectangle('Position',[x,y,w,h])
rectangle('Curvature',[x,y])
rectangle('PropertyName',propertyvalue,...)
h = rectangle(...)

Properties

For a list of properties, see Rectangle Properties.

Description

rectangle draws a rectangle with Position [0,0,1,1] and Curvature [0,0] (i.e., no curvature).

rectangle('Position',[x,y,w,h]) draws the rectangle from the point x,y and having a width of w and a height of h. Specify values in axes data units.

Note that, to display a rectangle in the specified proportions, you need to set the axes data aspect ratio so that one unit is of equal length along both the x and y axes. You can do this with the command axis equal or daspect([1,1,1]).

rectangle('Curvature',[x,y]) specifies the curvature of the rectangle sides, enabling it to vary from a rectangle to an ellipse. The horizontal curvature x is the fraction of width of the rectangle that is curved along the top and bottom edges. The vertical curvature y is the fraction of the height of the rectangle that is curved along the left and right edges.

The values of x and y can range from 0 (no curvature) to 1 (maximum curvature). A value of [0,0] creates a rectangle with square sides. A value of [1,1] creates an ellipse. If you specify only one value for Curvature, then the same length (in axes data units) is curved along both horizontal and vertical sides. The amount of curvature is determined by the shorter dimension.

rectangle('PropertyName',propertyvalue,...) draws the rectangle using the values for the property name/property value pairs specified and default values for all other properties. For a description of the properties, see Rectangle Properties.

h = rectangle(...) returns the handle of the rectangle object created.


好的先学习这么多函数


Matlab中怎么操作换行输入,怎么续行输入?

1. Shift + Enter

2. 句末加三个点'...'


自:http://www.mathworks.se/help/techdoc/ 

我是MATLAB小菜鸟,好好学习


  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值