matlab常用函数

来源:互联网 发布:邮票淘宝 编辑:程序博客网 时间:2024/05/22 11:35

1.size()获取矩阵的行数或列数
s=size(A), 当只有一个输出参数时,返回一个行向量,该行向量的第一个元素时矩阵的行数,第二个元素是矩阵的列数。
[r,c]=size(A), 当有两个输出参数时,size函数将矩阵的行数返回到第一个输出变量r,将矩阵的列数返回到第二个输出变量c
size(A,n)如果在size函数的输入参数中再添加一项n,并用1或2为n赋值,则 size将返回矩阵的行数或列数。其中r=size(A,1)该语句返回的时矩阵A的行数, c=size(A,2) 该语句返回的时矩阵A的列数。


2.conv2
C=conv2(A,B)返回A,B卷积得到的矩阵

A=rand(5)

A =

0.7733    0.2961    0.6054    0.4071    0.03180.7065    0.3604    0.0829    0.6173    0.81720.5596    0.4379    0.4743    0.4797    0.39740.0013    0.0400    0.3350    0.3974    0.42520.9327    0.8844    0.5378    0.8274    0.5774

B=rand(3)

B =

0.6794    0.6296    0.88290.1516    0.4597    0.85820.0909    0.2504    0.2984

mesh=conv2(A,B,’valid’)

mesh =

2.2366    1.7291    1.75501.3160    1.3673    1.77632.1357    2.2233    2.2204

mesh=conv2(A,B,’full’)

mesh =

0.5253    0.6880    1.2804    0.9192    0.8124    0.3795    0.02810.5972    1.0900    1.7986    1.3840    1.7286    1.4236    0.74880.5576    1.2498    2.2366    1.7291    1.7550    1.7086    1.06170.1499    0.5613    1.3160    1.3673    1.7763    1.6018    0.96030.6847    1.3747    2.1357    2.2233    2.2204    1.8732    0.99320.1415    0.5668    1.3294    1.2637    1.1676    1.2006    0.62240.0848    0.3140    0.5487    0.4738    0.4202    0.3915    0.1723

mesh=conv2(A,B,’same’)

mesh =

1.0900    1.7986    1.3840    1.7286    1.42361.2498    2.2366    1.7291    1.7550    1.70860.5613    1.3160    1.3673    1.7763    1.60181.3747    2.1357    2.2233    2.2204    1.87320.5668    1.3294    1.2637    1.1676    1.2006

‘full’ — Return the full 2-D convolution.
‘same’ — Return the central part of the convolution, which is the same size as A.
‘valid’ — Return only parts of the convolution that are computed without zero-padded edges.


3.J=edgetaper(I,PSF)使用点扩散函数矩阵PSF对输入图像I的边缘进行模糊处理。PSF的大小不得超过图像任意维大小的一半.


4.

A=rand(3)

A =

0.9355    0.4629    0.80310.3359    0.5980    0.15690.8194    0.7714    0.6698

B = padarray(A,[2 2],’replicate’,’both’)

B =

0.9355    0.9355    0.9355    0.4629    0.8031    0.8031    0.80310.9355    0.9355    0.9355    0.4629    0.8031    0.8031    0.80310.9355    0.9355    0.9355    0.4629    0.8031    0.8031    0.80310.3359    0.3359    0.3359    0.5980    0.1569    0.1569    0.15690.8194    0.8194    0.8194    0.7714    0.6698    0.6698    0.66980.8194    0.8194    0.8194    0.7714    0.6698    0.6698    0.66980.8194    0.8194    0.8194    0.7714    0.6698    0.6698    0.6698

‘both’:Pads before the first element and after the last array element along each dimension. This is the default.
‘post’:Pad after the last array element along each dimension.
‘pre’:Pad before the first array element along each dimension.

‘circular’:Pad with circular repetition of elements within the dimension.
‘replicate’:Pad by repeating border elements of array.
‘symmetric’:Pad array with mirror reflections of itself.