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 ...
随机推荐
- JAVA 中的集合框架
java集合框架提供了一套性能优良.使用方便的接口和类,它们位于java.util包中 一.集合与数组 数组:(可以存储基本数据类型)是用来存现对象的一种容器,但是数组的长度固定,不适合在对象数量未知 ...
- HTTP的长连接和短连接(转)
一.什么是长连接 HTTP1.1规定了默认保持长连接(HTTP persistent connection ,也有翻译为持久连接),数据传输完成了保持TCP连接不断开(不发RST包.不四次握手),等待 ...
- cmscp实例笔记
1.迭代循环 [@NodeList;list] [#list list as node] [#if node.name == "产品试用"] [/#if] [#if node.na ...
- Centos7+httpd+fastcgi安装提示错误
搭建的环境: centos7 Apache/2.4.6 fastcgi2.4.6 rails4 在安装fastcgi的时候遇到了问题: 问题: ...... In file included from ...
- SQL之merge into(转)
简介 Merge关键字是一个神奇的DML关键字.它在SQL Server 2008被引入,它能将Insert,Update,Delete简单的并为一句.MSDN对于Merge的解释非常的短小精悍:”根 ...
- Linux-挂载命令
1.查询与自动挂载 mount:查询系统中已挂载的设备 mount -a :依据配置文件.etc/fsatb的内容,自动挂载 2.挂在命令格式 mount [-t 文件系统] [-o 特殊选项] 设备 ...
- python的单例模式--解决多线程的单例模式失效
单例模式 单例模式(Singleton Pattern) 是一种常用的软件设计模式,主要目的是确保某一个类只有一个实例存在.希望在整个系统中,某个类只能出现一个实例时,单例对象就能派上用场 比如,某个 ...
- H5实现登录
1.主要就是获取cookie并每次发送请求时都带着:登录请求 2.添加HTTP Cookie管理器 3.登录请求时,加正则表达式提取器 取出返回的cookie ①使用charles抓包查看cookie ...
- [转]C++ 智能指针详解
转自:http://blog.csdn.net/xt_xiaotian/article/details/5714477 C++ 智能指针详解 一.简介 由于 C++ 语言没有自动内存回收机制,程序员每 ...
- Ubuntu 安装arm-linux-gcc编译器
/********************************************************************************** * Ubuntu 安装arm-l ...