当前位置:网站首页>Matlab基础(1)——基础知识
Matlab基础(1)——基础知识
2022-07-30 11:28:00 【Myster_KID】
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 - 可以分为两类:单精度型和双精度型
- 单精度
float,占4字节,数值范围 3.4 × 1 0 − 38 − 3.4 × 1 0 38 3.4\times10^{-38}-3.4\times10^{38} 3.4×10−38−3.4×1038,最多7位有效数字 - 双精度
double,占8字节,数值范围 1.7 × 1 0 308 − 1.7 × 1 0 308 1.7\times10^{308}-1.7\times10^{308} 1.7×10308−1.7×10308,最多16位有效数字
- 单精度
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()
边栏推荐
- How to add data to the request header when feign is called remotely
- SCM engineers written questions induction summary
- 如何用Golang来手撸一个Blog - Milu.blog 开发总结
- English line break
- 电压继电器HDY-A/1-220VAC-1
- Based on the analysis of the acoustic channel cable tunnel positioning technology
- Explain the problem of change exchange in simple terms - the shell of the backpack problem
- Voltage relay HDY - vac - 1 A / 1-220
- 单片机工程师笔试题目归纳汇总
- 深入浅出零钱兑换问题——背包问题的套壳
猜你喜欢
随机推荐
电压继电器SRMUVS-100VAC-2H2D
如何用Golang来手撸一个Blog - Milu.blog 开发总结
小心 transmittable-thread-local 的这个坑
Verilog语法基础HDL Bits训练 07
C# 枚举类型 于xaml 中区别
Testability of Fuzzy Discrete Event Systems
stm32 RTC闹钟唤醒低功耗模式
Still using Swagger?I recommend this interface management artifact with zero code intrusion
高能产出!腾讯内部的MyCat中间件手册,理论实操齐下
Transfer Learning技术研修
[Cloud-Building Co-creation] Huawei Cloud and Hongmeng collaborate to cultivate innovative developers
AB test summary
I built another wheel: GrpcGateway
Reverse linked list - recursive inversion method
久经沙场的程序员居然也被某鱼的假程序员骗了,程序员之间的信任应该是最高的,他一个人毁了这种信任感
【云筑共创】华为云携手鸿蒙,端云协同,培养创新型开发者
柔性机械系统分布参数建模及其控制的研究与进展
周鸿祎:微软抄袭了360安全模式 所以成为美国最大的安全公司
Database transactions, JDBC operations and data types
域名怎么注册备案解析?









