matlab 一些命令

>> help nextpowe2

nextpowe2.m not found.

Use the Help browser Search tab to search the documentation, or

type "help help" for help command options, such as help for methods.

>> help nextpow2

NEXTPOW2 Next higher power of 2.

NEXTPOW2(N) returns the first P such that 2^P >= abs(N). It is

often useful for finding the nearest power of two sequence

length for FFT operations.

NEXTPOW2(X), if X is a vector, is the same as NEXTPOW2(LENGTH(X)).

Class support for input N or X:

float: double, single

See also log2, pow2.

Reference page in Help browser

doc nextpow2

>> help max

MAX Largest component.

For vectors, MAX(X) is the largest element in X. For matrices,

MAX(X) is a row vector containing the maximum element from each

column. For N-D arrays, MAX(X) operates along the first

non-singleton dimension.

[Y,I] = MAX(X) returns the indices of the maximum values in vector I.

If the values along the first non-singleton dimension contain more

than one maximal element, the index of the first one is returned.

MAX(X,Y) returns an array the same size as X and Y with the

largest elements taken from X or Y. Either one can be a scalar.

[Y,I] = MAX(X,[],DIM) operates along the dimension DIM.

When complex, the magnitude MAX(ABS(X)) is used, and the angle

ANGLE(X) is ignored. NaN\'s are ignored when computing the maximum.

Example: If X = [2 8 4 then max(X,[],1) is [7 8 9],

7 3 9]

max(X,[],2) is [8 and max(X,5) is [5 8 5

9], 7 5 9].

See also min, median, mean, sort.

Overloaded functions or methods (ones with the same name in other directories)

help timeseries/max.m

help quantizer/max.m

help fints/max.m

help localpoly/max.m

help localpspline/max.m

Reference page in Help browser

doc max

>>

nargin是用来判断输入变量个数的函数,这样就可以针对不同的情况执行不同的功能。通常可以用他来设定一些默认值,如下面的函数。

例子,函数test1的功能是输出a和b的和。如果只输入一个变量,则认为另一个变量为0,如果两个变量都没有输入,则默认两者均为0。

function y=test1(a,b)

if nargin==0

a=0;b=0;

elseif nargin==1

b=0;

end

y=a+b;

>> i=imread(\'mars.jpg\');

>> size(i)

ans =

1055 1200

>>

>> [PQ,n]=paddedsize(size(i));

>> n

n =

1

>>

>> [PQ,n]=paddedsize(size(i));

>> n

n =

1

>> PQ

PQ =

2110 2400

>> size(i)

ans =

1055 1200

>>

源代码:

function [PQ,n]=paddedsize(AB,CD,PARAM)

%

n=nargin;

if nargin==1

PQ=2*AB;

elseif nargin==2 & ~ischar(CD);

PQ=AB+CD-1;

PQ=2*ceil( PQ/2);

elseif nargin==2

m=max(AB);

P=2^nextpow2(2*m);

P=[P,P];

elseif nargin==3

m=max([AB,CD]);

P=2^nextpow2(2*m);

PQ=[P,P];

else

error(\'wrong number of inputs\')

end

>> [PQ,n]=paddedsize(size(i),size(i));

>> n

n =

2

>> PQ

PQ =

2110 2400

>>

>> [PQ,n]=paddedsize(size(i),size(i));

>> n

n =

2

>> PQ

PQ =

2110 2400

>> [PQ,n]=paddedsize(size(i),size(i));

>> n

n =

2

>> PQ

PQ =

2110 2400

>> m=max(size(i));

>> M

M =

8

>> P=2^nextpow2(2*m);

>> P

P =

4096

>> U=nextpow2(2*m);

>> U

U =

12

>> PQ=[P,P];

>> PQ

PQ =

4096 4096

>> ~ischar(size(i))

ans =

1

>> PQ=size(i)+size(i)-1

PQ =

2109 2399

>> PQ=2*ceil( PQ/2);

>> PQ

PQ =

2110 2400

>>