许可优化
许可优化
产品
产品
解决方案
解决方案
服务支持
服务支持
关于
关于
软件库
当前位置:服务支持 >  软件文章 >  MATLAB基础(1):基础知识详解与入门操作

MATLAB基础(1):基础知识详解与入门操作

阅读数 13
点赞 0
article_banner

Matlab基础(1)——基础知识

Matlab基础系列教程传送门:Matlab基础(0)——命令行常用指令Matlab基础(1)——基础知识Matlab基础(2)——向量与多项式Matlab基础(3)——元胞与结构体Matlab基础(4)——矩阵Matlab基础(5)——符号运算
Matlab进阶系列教程传送门Matlab绘图(1)——二维绘图


文章目录


常量


常量名称对应含义
pi圆周率
eps浮点相对精度,常用于防止0出现在分母上
inf(Inf)无穷大,如 1 / 0 1/0 1/0
NaN(nan)不定值,如 0 / 0 0/0 0/0、 ∞ / ∞ \infty/\infty ∞/∞、 0 × ∞ 0\times\infty 0×∞
i(j)复数中的虚数单位
realmin最小正浮点数
realmax最大正浮点数

ps. 常量可以被 赋值 ,使用命令clear+变量名或重启Matlab可以将常量恢复初始值。

数据类型
整型含义占用空间
char字符型1字节
unsigned char无符号字符型1字节
short短整型2字节
unsigned short无符号短整型2字节
int有符号整型4字节
unsigned int无符号整型4字节
long长整型4字节
unsigned long无符号长整型4字节

浮点型:

  • 十进制数形式:由数字和小数点组成
  • 指数形式:一般形式为 aEn,其中a为10进制数,n为10进制整数,表示 a × 1 0 n a\times10^n a×10n
  • 可以分为两类:单精度型和双精度型
       

ps. 使用命令format可以 控制 命令行的输出格式,参考help format

类型转换

nu = 123;
st = num2str(nu);  % '123'

遇到不熟悉的类型转换时,可以使用lookfor指令查找相关函数:

>> lookfor num2
num2cell                       - Convert numeric array into cell array.
num2hex                        - Convert singles and doubles to IEEE hexadecimal string format
num2str                        - Convert numbers to character representation
num2ruler                      - Convert numeric array to ruler-appropriate array datatype
enum2val                       - Converts an enumerated string to its numerical equivalent.
num2cell                       - Convert numeric codistributed array into cell array
num2str                        - overloaded for gpuArrays
num2mstr                       - Convert number to string in maximum precision.
iptnum2ordinal                 - Convert positive integer to ordinal string.
num2ordinal                    - Convert positive integer to ordinal character vector.
signal_num2str                 - Convert the number to a string.
num2goid                       - Converts numbers to Gene Ontology IDs.
num2str                        - Convert numbers to character representation
defnum2                        - Sets Default channel names
num2deriv                      - Numeric two-point network derivative function.
num2base                       - Convert stored integers to strings
num2sdec                       - Convert stored integers of array of fi objects to signed decimal representation
num2fixpt                      - Quantize a value using a Fixed-Point Designer representation.
num2alphaheaders               - Generate Alpha headers from a number (usually column).
>> 
运算符


算数运算符定义
+算数加
-算数减
*算数乘
.*点乘
^算数乘方
.^点乘方
\算数左除
.\点左除
/算数右除
./点右除
'矩阵共轭转置
.'矩阵转置,不求共轭

其中:

  • 左除a\b表示 b ÷ a b\div a b÷a,右除a/b表示 a ÷ b a\div b a÷b
  • A*B表示矩阵乘法,要求矩阵 A A A的第二维度与矩阵 B B B的第一维度相等,A.*B表示矩阵按位乘法,要求矩阵 A A A和矩阵 B B B的形状相同,对乘方具有一致要求
  • A+B要求矩阵 A A A和矩阵 B B B的形状相同,对算数减有一致要求
  • A+a表示对矩阵 A A A中的每个元素都 + a +a +a,对其他算数运算有一致要求
关系运算符定义
==等于
~=不等于
>(<)大于/小于
>=(<=)大于等于/小于等于
逻辑运算符定义
&逻辑与
``
~逻辑非
xor逻辑异或
any有非零元素则为真
all所有元素均非零则为真

ps. 有关优先级

  • 算数运算符 > 关系运算符 > 逻辑运算符
  • 逻辑运算符中,~具有最高优先级,&|优先级相同


复数及三角运算函数


复数运算函数对应含义
abs(z)返回绝对值或复数的模
theta=angle(z)返回复数的相位,范围 [ − π , π ] [-\pi,\pi] [−π,π]
z=complex(a,b)返回复数 z = a + b i z=a+bi z=a+bi
conj(z)返回复数的共轭
a=real(z)返回复数的实部
b=imag(z)返回复数的虚部
isreal(x)判断矩阵是否含有复数
unwrap平移相位角
cplxpair将复数排序为复共轭对组
三角运算函数对应含义
sin()正弦函数
cos()余弦函数
tan()正切函数
cot()余切函数
sec()正割函数
csc()余割函数

ps. 反 三角函数 =a+三角函数,如反正弦为asin()

免责声明:本文系网络转载或改编,未找到原创作者,版权归原作者所有。如涉及版权,请联系删


相关文章
技术文档
QR Code
微信扫一扫,欢迎咨询~
customer

online

联系我们
武汉格发信息技术有限公司
湖北省武汉市经开区科技园西路6号103孵化器
电话:155-2731-8020 座机:027-59821821
邮件:tanzw@gofarlic.com
Copyright © 2023 Gofarsoft Co.,Ltd. 保留所有权利
遇到许可问题?该如何解决!?
评估许可证实际采购量? 
不清楚软件许可证使用数据? 
收到软件厂商律师函!?  
想要少购买点许可证,节省费用? 
收到软件厂商侵权通告!?  
有正版license,但许可证不够用,需要新购? 
联系方式 board-phone 155-2731-8020
close1
预留信息,一起解决您的问题
* 姓名:
* 手机:

* 公司名称:

姓名不为空

姓名不为空

姓名不为空
手机不正确

手机不正确

手机不正确
公司不为空

公司不为空

公司不为空