Anda di halaman 1dari 19

1) realmin

Smallest positive normalized floating-point number Syntax n = realmin realmin('double') realmin('single') Description n = realmin returns the smallest positive normalized floating-point number in IEEE double precision. realmin('double') is the same as realmin with no arguments. realmin('single') returns the smallest positive normalized floating-point number in IEEE single precision. See Representation of Floating-Point Numbers for more information. realmax

Largest positive floating-point number Syntax n = realmax Description n = realmax returns the largest finite floating-point number in IEEE double precision. realmax('double') is the same as realmax with no arguments. realmax('single') returns the largest finite floating-point number in IEEE single precision. See Representation of Floating-Point Numbers for more information. Infinity Syntax Inf Inf('double') Inf('single') Inf(n) Inf(m,n) Inf(m,n,p,...) Inf(...,classname) Description Inf

Inf returns the IEEE arithmetic representation for positive infinity. Infinity results from operations like division by zero and overflow, which lead to results too large to represent as conventional floating-point values. Inf('double') is the same as Inf with no inputs. Inf('single') is the single precision representation of Inf. Inf(n) is an n-by-n matrix of Infs. Inf(m,n) or inf([m,n]) is an m-by-n matrix of Infs. Inf(m,n,p,...) or Inf([m,n,p,...]) is an m-by-n-by-p-by-... array of Infs.

Note The size inputs m, n, p, ... should be nonnegative integers. Negative integers are treated as 0.

Inf(...,classname) is an array of Infs of class specified by classname. classname must be either 'single' or 'double'. NaN

Not-a-Number Syntax NaN Description NaN returns the IEEE arithmetic representation for Not-a-Number (NaN). These result from operations which have undefined numerical results. NaN('double') is the same as NaN with no inputs. NaN('single') is the single precision representation of NaN. NaN(n) is an n-by-n matrix of NaNs. NaN(m,n) or NaN([m,n]) is an m-by-n matrix of NaNs. NaN(m,n,p,...) or NaN([m,n,p,...]) is an m-by-n-by-p-by-... array of NaNs.

Note The size inputs m, n, p, ... should be nonnegative integers. Negative integers are treated as 0.

NaN(...,classname) is an array of NaNs of class specified by classname. classname must be either 'single' or 'double'. pi

Ratio of circle's circumference to its diameter Syntax pi Description

pi returns the floating-point number nearest the value of . The expressions 4*atan(1) and imag(log(-1)) provide the same value. eps

Floating-point relative accuracy Syntax eps d = eps(X) eps('double') eps('single') Description eps returns the distance from 1.0 to the next largest double-precision number, that is eps = 2^(-52). d = eps(X) is the positive distance from abs(X) to the next larger in magnitude floating point number of the same precision as X. X may be either double precision or single precision. For all X, eps(X) = eps(-X) = eps(abs(X)) eps('double') is the same as eps or eps(1.0). eps('single') is the same as eps(single(1.0)) or single(2^-23). Except for numbers whose absolute value is smaller than realmin , if 2^E <= abs(X) < 2^(E+1), then eps(X) = 2^(E-23) if isa(X,'single') eps(X) = 2^(E-52) if isa(X,'double') For all X of class double such that abs(X) <= realmin, eps(X) = 2^(-1074). Similarly, for all X of class single such that abs(X) <= realmin('single'), eps(X) = 2^(-149). Replace expressions of the form: if Y < eps * ABS(X) with if Y < eps(X) 2) for

Execute statements specified number of times Syntax for index = values program statements : end Description

for index=values, program statements, end repeatedly executes one or more MATLAB statements in a loop. values has one of the following forms: initval:endval increments the index variable from initval to endval by 1, and repeats execution of program statements until index is greater than endval.

initval:step:endval increments index by the value step on each iteration, or decrements when step is negative. valArray creates a column vector index from subsequent columns of array valArray on each iteration. For example, on the first iteration, index = valArray(:,1). The loop executes for a maximum of n times, where n is the number of columns of valArray, given by numel(valArray, 1, :). The input valArray can be of any MATLAB data type, including a string, cell array, or struct.

If

Model if-else control flow Description The If block, along with If Action subsystems containing Action Port blocks, implements standard C-like if-else logic. The following shows a completed if-else control flow statement. In this example, the inputs to the If block determine the values of conditions represented as output ports. Each output port is attached to an If Action subsystem. The conditions are evaluated top down starting with the if condition. If a condition is true, its If Action subsystem is executed and the If block does not evaluate any remaining conditions. The preceding if-else control flow statement can be represented by the following pseudocode. if (u1 > 0) { body_1; } else if (u2 > 0){ body_2; } else { body_3; } You construct a Simulink if-else control flow statement like the preceding example as follows: 1. 2. Place an If block in the current system. Open the dialog of the If block and enter as follows:

Enter the Number of inputs field with the required number of inputs necessary to define conditions for the if-else control flow statement. Elements of vector inputs can be accessed for conditions using (row, column) arguments. For example, you can specify the fifth element of the vector u2 in the condition u2(5) > 0 in an If expression or Elseif expressions field.

Enter the expression for the if condition of the if-else control flow statement in the If expression field. This creates an if output port for the If block with a label of the form if(condition). This is the only required If Action signal output for an If block.

Enter expressions for any elseif conditions of the if-else control flow statement in the Elseif expressions field.

Use a comma to separate one condition from another. Entering these conditions creates an output port for the If block for each condition, with a label of the form elseif(condition). elseif ports are optional and not required for operation of the If block.

Check the Show else condition check box to create an else output port. The else port is optional and not required for the operation of the If block.

3.

Create If Action subsystems to connect to each of the if, else, and elseif ports. These consist of a subsystem with an Action Port block. When you place an Action Port block inside each subsystem, an input port named Action is added to the subsystem.

4.

Connect each if, else, and elseif port of the If block to the Action port of an If Action subsystem. When you make the connection, the icon for the If Action block is renamed to the type of the condition that it attaches to.

Note During simulation of an if-else control flow statement, the Action signal lines from the If block to the If Action subsystems turn from solid to dashed.

5.

In each If Action subsystem, enter the Simulink blocks appropriate to the body to be executed for the condition it handles.

Note All blocks in an If Action Subsystem must run at the same rate as the driving If block. You can achieve this by setting each block's sample time parameter to be either inherited (-1) or the same value as the If block's sample time.

6.

In the preceding example, the If Action subsystems are named body_1, body_2, and body_3.

end

Terminate block of code, or indicate last array index Syntax end Description end terminates for, while, switch, try, if, and parfor statements. Without an end statement, for, while, switch, try, if, and parfor wait for further input. Each end is paired with the closest previous unpaired for, while, switch, try, if, or parfor and serves to delimit its scope. end also marks the termination of a function, although in many cases it is optional. If your function contains one or more nested functions, then you must terminate every function in the file, whether nested or not, with end. This includes primary, nested, private, and subfunctions. The end function also serves as the last index in an indexing expression. In that context, end = (size(x,k)) when used as part of the kth index. Examples of this use are X(3:end) and X(1,1:2:end-1). When using end to grow an array, as in X(end+1)=5, make sure X exists first. You can overload the end statement for a user object by defining an end method for the object. The end method should have the calling sequence end(obj,k,n), where obj is the user object, k is the index in the expression where the end syntax is used, and n is the total number of indices in the expression. For example, consider the expression A(end-1,:)

The MATLAB software calls the end method defined for A using the syntax end(A,1,2)

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 the NextPlot 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 on sets 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 and LineStyleOrder 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. line

Create line object Syntax line line(X,Y) line(X,Y,Z) line(X,Y,Z,'PropertyName',propertyvalue,...) line('XData',x,'YData',y,'ZData',z,...) h = line(...) Description

line creates a line object in the current axes with default values x = [0 1] and y = [0 1]. You can specify the color, width, line style, and marker type, as well as other characteristics. The line function has two forms:

Automatic color and line style cycling. When you specify multiple line coordinate data as a column array using the informal syntax (i.e., the first three arguments are interpreted as the coordinates), line(X,Y,Z) MATLAB cycles through the axes ColorOrder and LineStyleOrder property values the way the plot function does. However, unlike plot, line does not call the newplot function.

Purely low-level behavior. When you call line with only property name/property value pairs, line('XData',x,'YData',y,'ZData',z) MATLAB draws a line object in the current axes using the default line color (see the colordef function for information on color defaults). Note that you cannot specify matrix coordinate data with the low-level form of the line function.

line(X,Y) adds the line defined in vectors X and Y to the current axes. If X and Y are matrices of the same size, line draws one line per column. line(X,Y,Z) creates lines in three-dimensional coordinates. line(X,Y,Z,'PropertyName',propertyvalue,...) creates a line 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 Line Properties. See the LineStyle and Marker properties for a list of supported values. line('XData',x,'YData',y,'ZData',z,...) creates a line in the current axes using the property values defined as arguments. This is the lowlevel form of the line function, which does not accept matrix coordinate data as the other informal forms described above. h = line(...) returns a column vector of handles corresponding to each line object the function creates. 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 < 2, linspace returns b. 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.

Note The size inputs m, n, p, ... should be nonnegative integers. Negative integers are treated as 0. If any trailing dimensions are 0, output B does not include those dimensions.

B = zeros(size(A)) returns an array the same size as A consisting of all zeros. Y = zeros with no arguments is the scalar 0. zeros(m, n,...,classname) or zeros([m,n,...],classname) is an m-by-n-by-... array of zeros of data type classname. classname is a string specifying the data type of the output. classname can have the following values: 'double', 'single', 'int8', 'uint8', 'int16', 'uint16', 'int32', 'uint32', 'int64', or 'uint64'. eye

Identity matrix Syntax Y = eye(n) Y = eye(m,n) Y = eye([m n]) Y = eye(size(A)) Y = eye Y = eye(m, n, classname) Description Y = eye(n) returns the n-by-n identity matrix. Y = eye(m,n) or Y = eye([m n]) returns an m-by-n matrix with 1's on the diagonal and 0's elsewhere. The size inputs m and n should be nonnegative integers. Negative integers are treated as 0. Y = eye(size(A)) returns an identity matrix the same size as A. Y = eye with no arguments is the scalar 1.

Y = eye(m, n, classname) is an m-by-n matrix with 1's of class classname on the diagonal and zeros of class classname elsewhere. classname is a string specifying the data type of the output. classname can take the following values: 'double', 'single', 'int8', 'uint8', 'int16', 'uint16', 'int32', 'uint32', 'int64', or 'uint64'. The identity matrix is not defined for higher-dimensional arrays. The assignment y = eye([2,3,4]) results in an error. rand

Uniformly distributed pseudorandom numbers Syntax r = rand(n) r = rand(m,n) r = rand([m,n]) r = rand(m,n,p,...) r = rand([m,n,p,...]) r = rand r = rand(size(A)) r = rand(..., 'double') r = rand(..., 'single') Description r = rand(n) returns an n-by-n matrix containing pseudorandom values drawn from the standard uniform distribution on the open interval (0,1). r = rand(m,n) or r = rand([m,n]) returns an m-by-n matrix. r = rand(m,n,p,...) or r = rand([m,n,p,...]) returns an m-by-n-byp-by-... array. r = rand returns a scalar. r = rand(size(A)) returns an array the same size as A. r = rand(..., 'double') or r = rand(..., 'single') returns an array of uniform values of the specified class. 6 num2str Convert number to string Syntax str = num2str(A) str = num2str(A, precision) str = num2str(A, format) Description

The num2str function converts numbers to their string representations. This function is useful for labeling and titling plots with numeric values. str = num2str(A) converts array A into a string representation str. Converted floating-point values have a maximum of four digits of precision, and an exponent if required. For integer values, num2str returns the exact string representation of the value. str = num2str(A, precision) converts the array A into a string representation str with the maximum number of digits specified by precision. str = num2str(A, format) converts array A using the supplied format, as described on the fprintf function reference page. By default, num2str displays floating point values using the '%11.4g' format (four significant digits in exponential or fixed-point notation, whichever is shorter). clf

Clear current figure window Syntax clf clf('reset') clf(fig) clf(fig,'reset') figure_handle = clf(...) Description clf deletes from the current figure all graphics objects whose handles are not hidden (i.e., their HandleVisibility property is set to on). clf('reset') deletes from the current figure all graphics objects regardless of the setting of their HandleVisibility property and resets all figure properties except Position, Units, PaperPosition, and PaperUnits to their default values. clf(fig) or clf(fig,'reset') clears the single figure with handle fig. figure_handle = clf(...) returns the handle of the figure. This is useful when the figure IntegerHandle property is off because the noninteger handle becomes invalid when the reset option is used (i.e., IntegerHandle is reset to on, which is the default). clear

Remove items from workspace, freeing up system memory Syntax clear clear name clear name1 name2 name3 ... clear global name clear -regexp expr1 expr2 ... clear global -regexp expr1 expr2 ... clear keyword clear('name1','name2','name3',...) Description clear removes all variables from the workspace, releasing them from system memory. clear name removes just the code file (function or script) or MEX-file function or variable name from your base workspace. If called from a function or script, clear name removes name from the workspace of just that function or script. You can use wildcards (*) to remove items selectively. For example, clear my* removes any variables whose names begin with the string my. Clearing removes debugging breakpoints in code files and, when called from within a function with persistent variables, reinitializes the persistent variables. If name is global, clear removes it from the current workspace, but it remains accessible to any functions declaring it global. If name has been locked by mlock, it remains in memory. Use a partial path to distinguish between different overloaded versions of a function. For example, clear polynom/display clears only the display method for polynom objects, leaving any other implementations in memory. clear name1 name2 name3 ... removes name1, name2, and name3 from the workspace. clear global name removes the global variable name. If name is global, clear name removes name from the current workspace, but leaves it accessible to any functions declaring it as global. Use clear global name to remove a global variable completely. clear -regexp expr1 expr2 ... clears all variables that match any of the regular expressions listed. This option only clears variables.

clear global -regexp expr1 expr2 ... clears all global variables that match any of the regular expressions listed. clear keyword clears the items indicated by keyword. See the following section, Input Arguments, for a list of keywords and their descriptions. clear('name1','name2','name3',...) is the function form of the syntax. Use this form for variable names and function names stored in strings. If you name a variable all, classes, functions, java, import, or variables, calling clear followed by that name deletes the variable with that name. clear does not interpret the name as a keyword in this context. For example, if the workspace contains variables a, all, b, and ball, clear all deletes the variable all only. You can clear the handle of a figure or other object, but that does not remove the object itself. Use delete to remove objects and files. Deleting an object does not delete the variable, if any, used for storing its handle. On UNIX systems, clear does not affect the amount of memory allocated to the MATLAB process. The clear function does not clear Simulink models. Use close instead. disp

Display text or array Syntax disp(X) Description disp(X) displays an array, without printing the array name. If X contains a text string, the string is displayed. Another way to display an array on the screen is to type its name, but this prints a leading "X=," which is not always desirable. The disp function accepts only one input. To display more than one array or string, you can use concatenation or the sprintf or fprintf functions as shown in Example 3 Display multiple items on the same line. Note that disp does not display empty arrays. figure Create figure graphics object Syntax

figure figure('PropertyName',propertyvalue,...) figure(h) h = figure(...) 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 h. figure(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. plot

2-D line plot Syntax plot(Y) plot(X1,Y1,...,Xn,Yn) plot(X1,Y1,LineSpec,...,Xn,Yn,LineSpec) plot(X1,Y1,LineSpec,'PropertyName',PropertyValue) plot(axes_handle,X1,Y1,LineSpec,'PropertyName',PropertyValue) h = plot(X1,Y1,LineSpec,'PropertyName',PropertyValue) Description plot(Y) plots the columns of Y versus the index of each value when Y is a real number. For complex Y, plot(Y) is equivalent to plot(real(Y),imag(Y)). plot(X1,Y1,...,Xn,Yn) plots each vector Yn versus vector Xn on the same axes. If one of Yn or Xn is a matrix and the other is a vector, plots the vector versus the matrix row or column with a matching dimension to the vector. If Xn is a scalar and Yn is a vector, plots discrete Yn points vertically at Xn. If Xn or Yn are complex, imaginary components are ignored. If Xn or Yn are matrices, they must be 2-D and the same size, and the columns of Yn are plotted against the columns of Xn. plot automatically chooses colors and line styles in the order specified by ColorOrder and LineStyleOrder properties of current axes. plot(X1,Y1,LineSpec,...,Xn,Yn,LineSpec) plots lines defined by the Xn,Yn,LineSpec triplets, where LineSpec specifies the line type, marker symbol, and color. You can mix Xn,Yn,LineSpec triplets with Xn,Yn pairs: plot(X1,Y1,X2,Y2,LineSpec,X3,Y3). plot(X1,Y1,LineSpec,'PropertyName',PropertyValue) manipulates plot characteristics by setting lineseries properties (of lineseries graphics objects created by plot). Enter properties as one or more name and value pairs. plot(axes_handle,X1,Y1,LineSpec,'PropertyName',PropertyValue) plots using axes with the handle axes_handle instead of the current axes (gca). h = plot(X1,Y1,LineSpec,'PropertyName',PropertyValue) returns a column vector of handles to lineseries objects, one handle per line. subplot

Create axes in tiled positions Syntax h = subplot(m,n,p) or subplot(mnp) subplot(m,n,p,'replace') subplot(m,n,P) subplot(h) subplot('Position',[left bottom width height]) subplot(..., prop1, value1, prop2, value2, ...) h = subplot(...)

Description subplot divides the current figure into rectangular panes that are numbered rowwise. Each pane contains an axes object which you can manipulate using Axes Properties. Subsequent plots are output to the current pane. h = subplot(m,n,p) or subplot(mnp) breaks the figure window into an m-by-n matrix of small axes, selects the pth axes object for the current plot, and returns the axes handle. The axes are counted along the top row of the figure window, then the second row, etc. For example, subplot(2,1,1), plot(income) subplot(2,1,2), plot(outgo) plots income on the top half of the window and outgo on the bottom half. If the CurrentAxes is nested in a uipanel, the panel is used as the parent for the subplot instead of the current figure. The new axes object becomes the current axes. subplot(m,n,p,'replace') If the specified axes object already exists, delete it and create a new axes. subplot(m,n,P), where P is a vector, specifies an axes position that covers all the subplot positions listed in P, including those spanned by P. For example, subplot(2,3,[2 5]) creates one axes spanning positions 2 and 5 only (because there are no intervening locations in the grid), while subplot(2,3,[2 6]) creates one axes spanning positions 2, 3, 5, and 6. subplot(h) makes the axes object with handle h current for subsequent plotting commands. subplot('Position',[left bottom width height]) creates an axes at the position specified by a four-element vector. left, bottom, width, and height are in normalized coordinates in the range from 0.0 to 1.0. subplot(..., prop1, value1, prop2, value2, ...) sets the specified property-value pairs on the subplot axes object. Available property/value pairs are described more fully in Axes Properties. To add the subplot to a specific figure or uipanel, pass the handle as the value for the Parent property. You cannot specify both a Parent and a Position; that is, subplot('Position',[left bottom width height], 'Parent',h) is not a valid syntax. h = subplot(...) returns the handle to the new axes object. griddata

Data gridding TriScatteredInterp is the recommended alternative to griddata as it is generally more efficient. Syntax ZI = griddata(x,y,z,XI,YI) [XI,YI,ZI] = griddata(x,y,z,XI,YI) [...] = griddata(...,method) Description ZI = griddata(x,y,z,XI,YI) fits a surface of the form z = f(x,y) to the data in the (usually) nonuniformly spaced vectors (x,y,z). griddata interpolates this surface at the points specified by (XI,YI) to produce ZI. The surface always passes through the data points. XI and YI usually form a uniform grid (as produced by meshgrid). XI can be a row vector, in which case it specifies a matrix with constant columns. Similarly, YI can be a column vector, and it specifies a matrix with constant rows. [XI,YI,ZI] = griddata(x,y,z,XI,YI) returns the interpolated matrix ZI as above, and also returns the matrices XI and YI formed from row vector XI and column vector YI. These latter are the same as the matrices returned by meshgrid.

[...] = griddata(...,method) uses the specified interpolation method: 'linear' 'cubic' Triangle-based linear interpolation (default) Triangle-based cubic interpolation

'nearest' Nearest neighbor interpolation 'v4' MATLAB 4 griddata method

The method defines the type of surface fit to the data. The 'cubic' and 'v4' methods produce smooth surfaces while 'linear' and 'nearest' have discontinuities in the first and zero'th derivatives, respectively. All the methods except 'v4' are based on a Delaunay triangulation of the data. If method is [], then the default 'linear' method is used. [...] = griddata(...,options) specifies a cell array of strings options that were previously used by Qhull. Qhull-specific options are no longer required and are currently ignored. Support for these options will be removed in a future release. Occasionally, griddata might return points on or very near the convex hull of the data as NaNs. This is because roundoff in the computations sometimes makes it difficult to determine if a point near the boundary is in the convex hull. meshgrid

Generate X and Y arrays for 3-D plots Syntax [X,Y] = meshgrid(x,y) [X,Y] = meshgrid(x) [X,Y,Z] = meshgrid(x,y,z) Description [X,Y] = meshgrid(x,y) transforms the domain specified by vectors x and y into arrays X and Y, which can be used to evaluate functions of two variables and three-dimensional mesh/surface plots. The rows of the output array X are copies of the vector x; columns of the output array Y are copies of the vector y. [X,Y] = meshgrid(x) is the same as [X,Y] = meshgrid(x,x). [X,Y,Z] = meshgrid(x,y,z) produces three-dimensional arrays used to evaluate functions of three variables and three-dimensional volumetric plots. shading

Set color shading properties Syntax shading flat shading faceted shading interp shading(axes_handle,...) Description The shading function controls the color shading of surface and patch graphics objects. shading flat each mesh line segment and face has a constant color determined by the color value at the endpoint of the segment or the corner of the face that has the smallest index or indices.

shading faceted flat shading with superimposed black mesh lines. This is the default shading mode. shading interp varies the color in each line segment and face by interpolating the colormap index or true color value across the line or face. shading(axes_handle,...) applies the shading type to the objects in the axes specified by axes_handle, instead of the current axes. surf

3-D shaded surface plot Syntax surf(Z) surf(Z,C) surf(X,Y,Z) surf(X,Y,Z,C) surf(...,'PropertyName',PropertyValue) surf(axes_handles,...) surfc(...) h = surf(...) Description Use surf and surfc to view mathematical functions over a rectangular region. surf and surfc create colored parametric surfaces specified by X, Y, and Z, with color specified by Z or C. surf(Z) creates a a three-dimensional shaded surface from the z components in matrix Z, using x = 1:n and y = 1:m, where [m,n] = size(Z). The height, Z, is a single-valued function defined over a geometrically rectangular grid. Z specifies the color data as well as surface height, so color is proportional to surface height. surf(Z,C) plots the height of Z, a single-valued function defined over a geometrically rectangular grid, and uses matrix C, assumed to be the same size as Z, to color the surface. surf(X,Y,Z) creates a shaded surface using Z for the color data as well as surface height. X and Y are vectors or matrices defining the x and y components of a surface. If X and Y are vectors, length(X) = n and length(Y) = m, where [m,n] = size(Z). In this case, the vertices of the surface faces are (X(j), Y(i), Z(i,j)) triples. To create X and Y matrices for arbitrary domains, use the meshgrid function. surf(X,Y,Z,C) creates a shaded surface, with color defined by C. MATLAB performs a linear transformation on this data to obtain colors from the current colormap. surf(...,'PropertyName',PropertyValue) specifies surface properties along with the data. surf(axes_handles,...) and surfc(axes_handles,...) plot into the axes with handle axes_handle instead of the current axes (gca). surfc(...) draws a contour plot beneath the surface. h = surf(...) and h = surfc(...) return a handle to a surfaceplot graphics object. mod

Modulus after division Syntax M = mod(X,Y)

Description M = mod(X,Y) if Y ~= 0, returns X - n.*Y where n = floor(X./Y). If Y is not an integer and the quotient X./Y is within roundoff error of an integer, then n is that integer. The inputs X and Y must be real arrays of the same size, or real scalars. The following are true by convention:

mod(X,0) is X mod(X,X) is 0 mod(X,Y) for X~=Y and Y~=0 has the same sign as Y.

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.

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. 3)

fopen

Open file, or obtain information about open files Syntax fileID = fopen(filename) fileID = fopen(filename, permission) fileID = fopen(filename, permission, machineformat) fileID = fopen(filename, permission, machineformat, encoding) [fileID, message] = fopen(filename, ...) fIDs = fopen('all') [filename, permission, machineformat, encoding] = fopen(fileID)

Description fileID = fopen(filename) opens the file filename for read access, and returns an integer file identifier. fileID = fopen(filename, permission) opens the file with the specified permission. fileID = fopen(filename, permission, machineformat) specifies the order for reading or writing bytes or bits in the file. fileID = fopen(filename, permission, machineformat, encoding) specifies the character encoding scheme associated with the file. [fileID, message] = fopen(filename, ...) opens a file. If the operation fails, message is a system-dependent error message. Otherwise, message is an empty string. fIDs = fopen('all') returns a row vector containing the file identifiers of all open files. [filename, permission, machineformat, encoding] = fopen(fileID) returns the file name, permission, machine format, and encoding that a previous call to fopen used when it opened the specified file. fopen does not read information from the file to determine these output values. An invalid fileID returns empty strings for all output arguments.

fclose

Close one or all open files Syntax fclose(fileID) fclose('all') status = fclose(...) Description fclose(fileID) closes an open file. fileID is an integer file identifier obtained from fopen. fclose('all') closes all open files. status = fclose(...) returns a status of 0 when the close operation is successful. Otherwise, it returns -1.

load

Load data from MAT-file into workspace Syntax S = load(filename) S = load(filename, variables) S = load(filename, '-mat', variables) S = load(filename, '-ascii') load(...) load ... Description S = load(filename) loads the variables from a MAT-file into a structure array, or data from an ASCII file into a double-precision array. S = load(filename, variables) loads the specified variables from a MAT-file.

S = load(filename, '-mat', variables) forces load to treat the file as a MAT-file, regardless of the extension. Specifying variables is optional. S = load(filename, '-ascii') forces load to treat the file as an ASCII file, regardless of the extension. load(...) loads without combining MAT-file variables into a structure array. load ... is the command form of the syntax, for convenient loading from the command line. With command syntax, you do not need to enclose input strings in single quotation marks. Separate inputs with spaces instead of commas. Do not use command syntax if inputs such as filename are variables.

save

Save workspace variables to file Syntax save(filename) save(filename, variables) save(filename, '-struct', structName, fieldNames) save(filename, ..., '-append') save(filename, ..., format) save(filename, ..., version) save filename ... Description save(filename) stores all variables from the current workspace in a MATLAB formatted binary file (MAT-file) called filename. save(filename, variables) stores only the specified variables. save(filename, '-struct', structName, fieldNames) stores the fields of the specified scalar structure as individual variables in the file. If you include the optional fieldNames, the save function stores only the specified fields of the structure. You cannot specify variables and the '-struct' keyword in the same call to save. save(filename, ..., '-append') adds new variables to an existing file. You can specify the '-append' option with additional inputs such as variables, '-struct' , format, or version. save(filename, ..., format) saves in the specified format: '-mat' or '-ascii'. You can specify the format option with additional inputs such as variables, '-struct' , '-append', or version. save(filename, ..., version) saves to MAT-files in the specified version: '-v4', '-v6', '-v7', or '-v7.3'. You can specify the version option with additional inputs such as variables, '-struct' , '-append', or format. save filename ... is the command form of the syntax, for convenient saving from the command line. With command syntax, you do not need to enclose input strings in single quotation marks. Separate inputs with spaces instead of commas. Do not use command syntax if inputs such as filename are variables. diary Save Command Window text to file Syntax diary diary('filename') diary off

diary on diary filename Description The diary function creates a log of keyboard input and the resulting text output, with some exceptions (see Tips for details). The output of diary is an ASCII file, suitable for searching in, printing, inclusion in most reports and other documents. If you do not specify filename, the MATLAB software creates a file named diary in the current folder. diary toggles diary mode on and off. To see the status of diary, type get(0,'Diary'). MATLAB returns either on or off indicating the diary status. diary('filename') writes a copy of all subsequent keyboard input and the resulting output (except it does not include graphics) to the named file, where filename is the full pathname or filename is in the current MATLAB folder. If the file already exists, output is appended to the end of the file. You cannot use a filename called off or on. To see the name of the diary file, use get(0,'DiaryFile'). diary off suspends the diary. diary on resumes diary mode using the current filename, or the default filename diary if none has yet been specified. diary filename is the unquoted form of the syntax.

Anda mungkin juga menyukai