当前位置:网站首页>MATLAB program design and application 2.4 Common internal functions of MATLAB
MATLAB program design and application 2.4 Common internal functions of MATLAB
2022-07-31 20:11:00 【Ding Jiaxiong】
MATLAB程序设计与应用
文章目录
2. 第2章 MATLABData and its arithmetic
2.4 MATLAB常用内部函数
Internal function is by MATLAB System according to the needs of general users provide users with a set of program,Also known as the system function or library function.
2.4.1 常用数学函数
MATLAB提供了许多数学函数,函数的自变量规定为矩阵变量,运算法则是将函数逐项作用于矩阵的元素上,Thus the result of the operation was a and the independent variables with the same dimension and size of matrix,With independent variable matrix is the matrix type.
>> A = [4,2;3,6]
A =
4 2
3 6
>> B = sqrt(A)
B =
2.0000 1.4142
1.7321 2.4495
常用的数学函数
函数名 | 功能 | 函数名 | 功能 |
---|---|---|---|
sin/sind | 正弦函数,The input values for arc/角度 | abs | 绝对值函数 |
cos/cosd | 余弦函数,The input values for arc/角度 | rem | 求余 |
tan/tand | 正切函数,The input values for arc/角度 | mod | 求模 |
asin/asind | 反正弦函数,The return value for arc/角度 | fix | 向零方向取整 |
acos/acosd | 反余弦函数,The return value for arc/角度 | floor | 不大于自变量的最大整数 |
atan/atand | 反正切函数,The return value for arc/角度 | ceil | 不小于自变量的最小整数 |
sinh/asinh | 双曲正弦函数/反双曲正弦函数 | round | 四舍五入到最邻近的整数 |
cosh/acosh | 双曲余弦函数/反双曲余弦函数 | sign | 符号函数 |
tanh/atanh | 双曲正切函数/反双曲正切函数 | gcd | 最大公约数 |
sqrt | 平方根函数 | lcm | 最小公倍数 |
log | 自然对数函数 | factorial | 阶乘 |
log10 | 常用对数函数 | isprime | 判断是否为素数 |
log2 | 以2为底的对数函数 | primes | Generate prime number list |
exp | 自然指数函数 | perms | 生成所有排列 |
pow2 | 2的幂 | randperm | To generate arbitrary arrangement |
使用说明:
三角函数有以弧度为单位的函数和以角度为单位的函数,In the Angle of function in the function name followed“d”,以示区别.
abs函数可以求实数的绝对值、复数的模、字符串的ASCII码值.例如, abs(-4). abs(3+4i)、abs(‘a’)的值分别为4、5、97.
Seek more operation and operator have the same place, but not quite the same,The main difference is that for negative integer division when the operation of different.对于整数a、 b来说,Seek more operations or modular arithmetic method is first integer quotientc=a/b,
Strives for the remainder or dier=a-c*b.Residual operation in takec的值时,向0方向取整(fix函数),For modular arithmetic in the calculationc的值时,向负无穷方向取整(floor函数).rem与 mod 函数的区别是,当b≠0时,rem(a,b)=a-b.*fix(a./b),而mod(a,b)=a-b.*floor(a/b);当b=0时,rem(a,0)=NaN 而mod(a,0)=a.
显然,如果a、b符号相同,那么rem(a,b)=mod(a,b).如果a、b符号相反,那么
mod(a,b)=rem(a,b)+b.rem(a,b)的符号与a相同,而 mod(a,b)的符号与b相同.例如,rem(7,4)=mod(7,4)=3;rem(-7,-4)=mod(-7,-4)=-3;rem(7,-4)=3,而 mod(7,-4)=-1:rem(-7,4)-3,而mod(-7,4)=1 .用于取整的函数有fix、floor、ceil、round,要注意它们的区别.round The round () function.设a为最靠近x的正整数(|x|≥a),则其余3The difference between a function:
设x=2.45,则fix(x)、floor(x)、ceil(x)、round(x)的结果分别是2、2、3、2.又设x=-2.65,则fix(x)、floor(x)、 ceil(x)、 round(x)的结果分别是-2、-3、-2、-3.
- About function.当x<0时,sign(x)=-1:当x=0时,sign(x)=0:当x>0时,sign(x)=1.
2.4.2 Matrix of transcendental function
MATLABAlso provides some direct effects on the matrix of transcendental function,The function names in the internal function name suffix tom,And the input parametersA必须是方阵.
矩阵平方根
sqrtm(A)计算矩阵A的平方根√A.
>> A = [4,2;3,6]; >> B = sqrtm(A) B = 1.9171 0.4652 0.6978 2.3823 >> B * B ans = 4.0000 2.0000 3.0000 6.0000
若AFor real symmetric positive definite matrices or complex Hermitian(Hermitian)正定阵,Also must be able to calculate the square root of it.But some matrix,如 A=[0,1;0,0]Won't get the square root.若矩阵AWith negative eigenvalues of,则sqrtm(A)Will be a complex matrix.
>> A = [4,9;16,25]; >> eig(A) ans = -1.4452 30.4452 >> B = sqrtm(A) B = 0.9421 + 0.9969i 1.5572 - 0.3393i 2.7683 - 0.6032i 4.5756 + 0.2053i
矩阵对数
logm(A)计算矩阵4 的自然对数.The function of input parameters and the conditions of the relationship between the output and the functionsqrtm(A)完全一样.
>> A = [4,9;1,5]; >> L = logm(A); >> L L = 1.0639 2.4308 0.2701 1.3340
矩阵指数
expm(A)The function of the matrix exponential is oe的A次幂.
L = 1.0639 2.4308 0.2701 1.3340 >> B = expm(L) B = 4.0000 9.0000 1.0000 5.0000
Common matrix function
funm(A,@fun)对方阵A计算由 funDefine the function of matrix function value.例如,当fun取exp时,funm(A,@exp)Matrix can be calculatedA的指数,与 expm(A)The calculation results of.
>> A = [2,-1;1,0]; >> funm(A,@exp) ans = 5.4366 -2.7183 2.7183 0 >> expm(A) ans = 5.4366 -2.7183 2.7183 0
funm函数可以用于 exp、log . sin、cos, sinh和 cosh等函数,But for the square root of matrix can only usesqrtm函数.
边栏推荐
- 【PIMF】OpenHarmony 啃论文俱乐部—盘点开源鸿蒙三方库【3】
- Bika LIMS 开源LIMS集—— SENAITE的使用(检测流程)
- MySQL---aggregate function
- Realize serial port receiving data based on STM32 ring queue
- 手把手教你学会部署Nestjs项目
- 全网一触即发,自媒体人的内容分发全能助手——融媒宝
- What's wrong with the sql syntax in my sql
- All-platform GPU general AI video supplementary frame super-score tutorial
- renderjs usage in uni-app
- 老牌音乐播放器 WinAmp 发布 5.9 RC1 版:迁移到 VS 2019 完全重建,兼容 Win11
猜你喜欢
中文编码的设置与action方法的返回值
The old music player WinAmp released version 5.9 RC1: migrated to VS 2019, completely rebuilt, compatible with Win11
嵌入式开发没有激情了,正常吗?
1161. Maximum Sum of Elements in Layer: Hierarchical Traversal Application Problems
leetcode: 6135. The longest ring in the graph [inward base ring tree + longest ring board + timestamp]
全平台GPU通用AI视频补帧超分教程
Socket Review and I/0 Model
The principle of ReentrantLock (to be continued)
Implementing a Simple Framework for Managing Object Information Using Reflection
Apache EventMesh distributed event-driven multi-runtime
随机推荐
[PIMF] OpenHarmony Thesis Club - Inventory of the open source Hongmeng tripartite library [3]
&lt;artifactId&gt;ojdbc8&lt;/artifactId&gt;「建议收藏」
MySQL---sort and pagination
顺序表的实现
程序员如何学习开源项目,这篇文章告诉你
请问我的这段sql中sql语法哪里出了错
SiC MOSFET的短路特性及保护
【公开课预告】:超分辨率技术在视频画质增强领域的研究与应用
leetcode 665. Non-decreasing Array
Implementation of a sequence table
Given an ip address, how does the subnet mask calculate the network number (how to get the ip address and subnet mask)
10 Ways to Keep Your Interface Data Safe
Arduino框架下STM32全系列开发固件安装指南
BM5 merge k sorted linked lists
Write a database document management tool based on WPF repeating the wheel (1)
广汽本田安全体验营:“危险”是最好的老师
1161. Maximum Sum of Elements in Layer: Hierarchical Traversal Application Problems
返回一个零长度的数组或者空的集合,不要返回null
Poker Game in C# -- Introduction and Code Implementation of Blackjack Rules
Realize serial port receiving data based on STM32 ring queue