matlab diag 函数
来源:互联网 发布:淘宝重复开店2017处罚 编辑:程序博客网 时间:2024/05/16 07:14
把向量生成矩阵:
v = [2 1 -1 -2 -5];
Use diag to create a matrix with the elements of v on the main diagonal.
D = diag(v)
D =
2 0 0 0 0
0 1 0 0 0
0 0 -1 0 0
0 0 0 -2 0
0 0 0 0 -5
Create a matrix with the elements of v on the first super diagonal (k=1).
D1 = diag(v,1)
D1 =
0 2 0 0 0 0
0 0 1 0 0 0
0 0 0 -1 0 0
0 0 0 0 -2 0
0 0 0 0 0 -5
0 0 0 0 0 0
The result is a 6-by-6 matrix. When you specify a vector of length n as an input, diag returns a square matrix of size n+abs(k).
对矩阵取对角线的值生成一个向量:
A = randi(10,6)
A =
9 3 10 8 7 8
10 6 5 10 8 1
2 10 9 7 8 3
10 10 2 1 4 1
7 2 5 9 7 1
1 10 10 10 2 9
x = diag(A)
x =
9
6
9
1
7
9
Get the elements on the first subdiagonal (k=-1) of A. The result has one fewer element than the main diagonal.
x1 = diag(A,-1)
x1 =
10
10
2
9
2
Calling diag twice returns a diagonal matrix composed of the diagonal elements of the original matrix.
来自MATLAB help
- matlab中的diag函数
- MATLAB中的diag函数
- matlab函数之diag
- matlab diag 函数
- MATLAB中的diag函数
- Matlab diag函数功能
- matlab中的diag,spdiags函数
- matlab中的diag,spdiags函数
- MATLAB 中的diag,spdiags函数
- matlab 之 diag 函数用法
- matlab 中diag函数的用法
- matlab 中diag函数的用法
- MATLAB中diag函数的作用
- diag函数
- matlab2c使用c++实现matlab函数系列教程-diag函数
- MATLAB中的diag()函数 构造对…
- Matlab学习笔记(3)——diag函数的使用
- Matlab diag的用法
- ContentProvider监听数据变化
- 对象指针
- 游戏基本元素2
- the method of type must override a superclass.
- 搜索框制作--AutoCompleteTextView
- matlab diag 函数
- HBase 1.1.3 中如何开发LoadBalance插件
- 动作
- POP3收取邮件
- HLJ 亲授 装逼技巧 IB_DESIGNABLE 在xib中不通过runtimeAttribute直接修改边的宽度和颜色
- FZU 2037Maximum Value Problem (打表预处理/找规律)
- HTTP响应头和请求头信息对照表
- 原生hessian配置
- 虚拟现实很火,但“虚火”要不得