博客
关于我
Matlab中的数组及其运算(可收藏待用)
阅读量:144 次
发布时间:2019-02-28

本文共 996 字,大约阅读时间需要 3 分钟。

本博文源于matlab基础,分享对数组的一些基础操作。

数组及其运算

定义数组(向量)

x=[1 2 3 4 5 6]或x=[1,2,3,4,5,6]x=[1 2 3;4 5 6;7 8 9]

定义一个3*3的矩阵

x=[1 2 3;4 5 6;7 8 9]

定义复杂数组(向量)

x=m:n 定义x为数组(m,m+1,m+2,....,n)x=m:k:n 定义x为数组(m,m+k,m+2k,...,n)x = linspace(m,n,k) 将[m,n]进行k等分,取其端点.

列向量

连用分号

x=[1;2;3;4;5]

如果已有行向量,直接’进行转换为列向量

y=x'

数组与数字间的四则运算

在matlab中,数组与数字之间可以定义加减乘除.设X=[a,b,c,d,e],q为标量,则有如下计算规则:

X+q = [a+q,b+q,c+q,d+q,e+q]X*q = [a*q,b*q,c*q,d*q,e*q]X/q = [a/q,b/q,c/q,d/q,e/q]X.\q = [q/a,q/b,q/c,q/d,q/e]

数组的幂运算

所谓的标量就是一个数字,设X=[a,b,c,d,e]

X.^q=[a^q,b^q,c^q,d^q,e^q]q.^X=[q^a,q^b,q^c,q^d,q^e]

数组与数组间的运算

设X=[a,b,c,d],Y=[e,f,g,h]

X+Y=[a+e,b+f,c+g,d+h]X./Y = [a/e,b/f,c/g,d/h]X.^Y = [a^e,b^e,c^g,d^h]X.*Y = [a*e,b*f,c*g,d*h]X.\y = [e/a,f/b,g/c,h/d]

数组之间做运算一定要用到点!!!

定义m*n单位矩阵

A=eye(m,n)

定义m*n零矩阵

B=zeros(m,n)

对矩阵中元素进行操作

提取行列

matlab中(行,列)

提取第1到2行,第2列到第3列就是这样写

A(1:2,2:3)

格式是

A(i:j,m:n)

删去部分行,留下剩余元素

A(i:j,:)

删去部分列,留下剩余元素

A(:,m:n)

矩阵合并

[A B] //A在左,B在右[A;B]//A在上,B在下

矩阵运算

同型矩阵相加  A+B两个矩阵相乘  A*B

求方阵的行列式

det(A)

求矩阵的逆矩阵

inv(A)

矩阵左除

A/B

矩阵右除

A\B

转载地址:http://tlrd.baihongyu.com/

你可能感兴趣的文章
Nmap渗透测试指南之指纹识别与探测、伺机而动
查看>>
Nmap端口扫描工具Windows安装和命令大全(非常详细)零基础入门到精通,收藏这篇就够了
查看>>
NMAP网络扫描工具的安装与使用
查看>>
NMF(非负矩阵分解)
查看>>
nmon_x86_64_centos7工具如何使用
查看>>
NN&DL4.1 Deep L-layer neural network简介
查看>>
NN&DL4.3 Getting your matrix dimensions right
查看>>
NN&DL4.7 Parameters vs Hyperparameters
查看>>
NN&DL4.8 What does this have to do with the brain?
查看>>
nnU-Net 终极指南
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
NO 157 去掉禅道访问地址中的zentao
查看>>
no available service ‘default‘ found, please make sure registry config corre seata
查看>>
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
查看>>
no connection could be made because the target machine actively refused it.问题解决
查看>>
No Datastore Session bound to thread, and configuration does not allow creation of non-transactional
查看>>
No fallbackFactory instance of type class com.ruoyi---SpringCloud Alibaba_若依微服务框架改造---工作笔记005
查看>>
No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalanc
查看>>
No mapping found for HTTP request with URI [/...] in DispatcherServlet with name ...的解决方法
查看>>