Diag:Diagonal matrices and diagonals of a matrix
Diag:Diagonal matrices and diagonals of a matrix
Syntax
X = diag(v,k)
X = diag(v)
v = diag(X,k)
v = diag(X)
Description
X = diag(v,k) when v is a vector of n components, returns a square matrix X of order n+abs(k), with the elements of v on the kth diagonal. k = 0 represents the main diagonal, k > 0 above the main diagonal, and k < 0 below the main diagonal.
X = diag(v) puts v on the main diagonal, same as above with k = 0.
v = diag(X,k) for matrix X, returns a column vector v formed from the elements of the kth diagonal of X.
v = diag(X) returns the main diagonal of X, same as above with k = 0.
example_
diag([1 2 3],-2) % 此时k=-2,注意黑色的部分
ans =
0 0 0 0 0
0 0 0 0 0
1 0 0 0 0
0 2 0 0 0
0 0 3 0 0
diag([1 2 3],2) % 此时k=2,注意黑色的部分
ans =
0 0 1 0 0
0 0 0 2 0
0 0 0 0 3
0 0 0 0 0
0 0 0 0 0
diag([1 2 3]) % 此时k=0,直接返回对角矩阵
ans =
1 0 0
0 2 0
0 0 3
diag([1 2 3;4 5 6; 7 8 9 ]) %若输入矩阵,返回对角
ans =
1
5
9
Diag:Diagonal matrices and diagonals of a matrix的更多相关文章
- block diagonal matrix 直和 块对角矩阵 不完美 有缺陷 缩放 射影几何
小结: 1.block diagonal matrix 直和 块对角矩阵 A block diagonal matrix is a block matrix that is a square mat ...
- 实用矩阵类(Matrix)(带测试)
引言: 无意间看到国外一个网站写的Matrix类,实现了加减乘除基本运算以及各自的const版本等等,功能还算比较完善,,于是记录下来,以备后用: #ifndef MATRIX_H #define M ...
- sparse matrix
w https://en.wikipedia.org/wiki/Sparse_matrix 稀疏矩阵存储格式总结+存储效率对比:COO,CSR,DIA,ELL,HYB - Bin的专栏 - 博客园ht ...
- codeforce 266c Below the Diagonal 矩阵变换 (思维题)
C. Below the Diagonal You are given a square matrix consisting of n rows and n columns. We assume th ...
- [Matlab] Galois Field arrays
Operations supported for Galois Field arrays: + - - Addition and subtraction of Galois arrays. * / \ ...
- Applying Eigenvalues to the Fibonacci Problem
http://scottsievert.github.io/blog/2015/01/31/the-mysterious-eigenvalue/ The Fibonacci problem is a ...
- HOG(方向梯度直方图)
结合这周看的论文,我对这周研究的Histogram of oriented gradients(HOG)谈谈自己的理解: HOG descriptors 是应用在计算机视觉和图像处理领域,用于目标检測 ...
- python 矩阵分成上三角下三角和对角三个矩阵
diagonal Return specified diagonals. diagflat Create a 2-D array with the flattened input as a diago ...
- [C2P1] Andrew Ng - Machine Learning
About this Course Machine learning is the science of getting computers to act without being explicit ...
随机推荐
- 在其他平台上使用 ActiveMQ
这一章讲了使用其他编程语言来访问 ActiveMQ,其他语言基本上都有相应的协议实现,所以说实现了协议,编程语言不是障碍! 还说了 ActiveMQ 提供了 RESTFul API 和 Ajax AP ...
- asp.net中异步调用webservice
WebService方法是不需要作任何修改的,只是在调用时采用异步的方式,这样在循环中,速度会显得快一点. 原来的方式: HotelMagWeb.com.china_sms.www.MainServi ...
- vue cli关闭eslint严格语法检查
eslint是一个JavaScript的校验插件,通常用来校验语法或代码的书写风格. 官方文档:https://eslint.org 这篇文章总结了eslint的规则:Eslint规则说明 1.关闭e ...
- sql语句中as的用法和作用
最近做项目中,偶然发现在SQL语句中出现了as这个词,一直以来没怎么关注是什么意思,毕竟影响不大,今天有空,就在网上查了一些资料,大概有了一些的了解 我们的Sql语句在很多数据库中都是通用的,比如像M ...
- hive_学习_00_资源帖
一.官方资料 二.参考资料
- Java NIO阻塞式通信
package com.nio.t; import java.io.IOException; import java.net.InetSocketAddress; import java.nio.By ...
- 深入探索C++对象模型 读书笔记
第1章 关于对象 1.C++在布局以及存取时间上的主要的额外负担是由virtual引起的,包括: a.virtual function机制,引入vptr以及vtbl,支持一个有效率的"执行期 ...
- [转]C++ 智能指针详解
转自:http://blog.csdn.net/xt_xiaotian/article/details/5714477 C++ 智能指针详解 一.简介 由于 C++ 语言没有自动内存回收机制,程序员每 ...
- WPF之ContextMenu的命定绑定
在WPF中右击菜单项的XMAL代码是: <ContextMenu x:Key="sampleContextMenu"> <MenuItem Header=&quo ...
- 自动化框架httpClient实例
package com.auto.test.util; import java.net.SocketException;import java.net.SocketTimeoutException;i ...