Matlab内置大量函数,那么我们该如何使用这些函数呢。有时候,我们不知道该如何使用函数,比如函数的输入参数和输出参数是怎么样的。这个问题,其实Matlab早就想到了。于是,Matlab还内置了这些函数的帮助说明以及文档说明。
所有 MATLAB® 函数都有辅助文档,这些文档包含一些示例,并介绍函数输入、输出和调用语法。从命令行访问此信息有多种方法:下面我们以函数mean来讲解如何获取帮助和文档。
- 使用
doc
命令在单独的窗口中打开函数文档。
doc mean
这时,Matlab会弹出一个文档页面,里面会给出mean函数的使用方法,并且会给出几个例子说明。
- 在键入函数输入参数的左括号之后暂停,此时命令行窗口中会显示相应函数的提示(函数文档的语法部分)。
mean(
- 使用
help
命令可在命令行窗口中查看相应函数的简明文档。
>> help mean
mean Average or mean value.
S = mean(X) is the mean value of the elements in X if X is a vector.
For matrices, S is a row vector containing the mean value of each
column.
For N-D arrays, S is the mean value of the elements along the first
array dimension whose size does not equal 1.
mean(X,DIM) takes the mean along the dimension DIM of X.
S = mean(..., TYPE) specifies the type in which the mean is performed,
and the type of S. Available options are:
'double' - S has class double for any input X
'native' - S has the same class as X
'default' - If X is floating point, that is double or single,
S has the same class as X. If X is not floating point,
S has class double.
S = mean(..., MISSING) specifies how NaN (Not-A-Number) values are
treated. The default is 'includenan':
'includenan' - the mean of a vector containing NaN values is also NaN.
'omitnan' - the mean of a vector containing NaN values is the mean
of all its non-NaN elements. If all elements are NaN,
the result is NaN.
Example: If X = [1 2 3; 3 3 6; 4 6 8; 4 7 7];
then mean(X,1) is [3 4.5 6] and mean(X,2) is [2; 4; 6; 6]
Class support for input X:
float: double, single
integer: uint8, int8, uint16, int16, uint32,
int32, uint64, int64
转载文章,原文出处:MathWorks官网,由古哥整理发布
如若转载,请注明出处:https://iymark.com/articles/2876.html