matlab实现判断是否能否生成严格对角占优矩阵
如题:
function X = IsStrictDiagMatrix(A)
% input: A matrix
% output: The matrix after transformation
% if the matrix is not a square matrix, return error
if size(A, 1) ~= size(A, 2)
error('It is not a square matrix');
end
% get the size of A and set the size of X
% use an array to accord if all the row be set
N = size(A, 1);
X = zeros(N, N);
has_set = zeros(N);
for i = 1 : N
% find out the max element in a row
row_max = max(abs(A(i, : )));
% if the max element is not larger than sum of others, return error
if (row_max <= (sum(abs(A(i, : ))) - row_max))
error('It can not be transformed to strict diagonal dominance matrix');
end
% find out the index of max element and set the row j of matrix X
% accord row j has been set
for j = 1 : N
if (abs(A(i, j)) == row_max)
X(j, : ) = A(i, : );
has_set(j) = 1;
end
end
end
% if any hasn't been set, return error
for i = 1 : N
if (has_set == 0)
error('It can not be transformed to strict diagonal dominance matrix');
end
end
% output success
fprintf('It can be transformed to a strict diagonal dominance matrix: \n');
end
matlab实现判断是否能否生成严格对角占优矩阵的更多相关文章
- MATLAB高斯混合数据的生成
MATLAB高斯混合数据的生成 作者:凯鲁嘎吉 - 博客园 http://www.cnblogs.com/kailugaji/ 高斯混合模型的基本原理:聚类——GMM,MATLAB中GMM聚类算法:M ...
- matlab中元胞数组(cell)转换为矩阵
matlab中元胞数组(cell)转换为矩阵. cell转换为矩阵函数为:cell2mat(c),其中c为待转换的元胞数组: 转化之后的矩阵可能不满足我们对矩阵维数的要求,那么也许还需要下面两个函数: ...
- MATLAB小函数:将列向量转化为0-1矩阵
MATLAB小函数:将列向量转化为0-1矩阵 作者:凯鲁嘎吉 - 博客园 http://www.cnblogs.com/kailugaji/ 将列向量转化为0-1矩阵,例如 A = 1 2 1 5 3 ...
- matlab inpolygon 判断点在多边形内
如何判断一个点在多边形内部? xv= [0 3 3 0 0]; %x坐标 yv= [0 0 3 3 0];%y坐标 x=1.5; y=1.5; in=inpolygon(x,y,xv,yv) plot ...
- 【转载】matlab如何判断一个点是否在多面体内
转载自:http://www.52souji.net/point-within-a-polyhedron/ 我遇到的一个实际问题是:要在空位区域随机放置一定数量的原子,这些原子在空位区域任何一处存在的 ...
- matlab (.m)文件生成 windows 可执行(.exe)文件
mex -setup:设置 C 语言编译器:(如果本地安装有 visual studio 20xx 集成开发环境,则会自动选择其下的 C/C++ 编译器 ) 将运行时环境(runtime enviro ...
- Matlab绘图基础——散点生成三角网(TIN)
%例一:二维三角网TIN模型的生成 X=rand(10,2)*5; dt=DelaunayTri(X(:,1),X(:,2)); %生成三角网 triplot(dt);hold on; ...
- matlab中randi代替randint生成随机均匀分布信号的用法
%%新函数 2*randi([0,1],2,1)-1 等价于老函数 2*randint(2,1)-1 函数形式:randi([imin,imax],m,n) 参数解释: [imin,im ...
- java学习-zxing生成二维码矩阵的简单例子
这个例子需要使用google的开源项目zxing的核心jar包 core-3.2.0.jar 可以百度搜索下载jar文件,也可使用maven添加依赖 <dependency> <gr ...
随机推荐
- javascript跨域请求RESTful Web Service
跨域请求RESTful Web Service 当我们用js请求RESTful Web Service的时候,通常会出现跨域无法访问的问题,也就是无法正常得到我们要的值.jsonp是个解决问题的方法. ...
- codeforces 676B B. Pyramid of Glasses(模拟)
题目链接: B. Pyramid of Glasses time limit per test 1 second memory limit per test 256 megabytes input s ...
- C#之使用随机数
1.C#自带随机数函数 using System; System.Random ran = new System.Random();int n = ran.Next(100, 1000);//产生10 ...
- spring项目中如何添加定时器以及在定时器中自动生成sprng注入对象
最近做了一个java的项目,部门领导给了一套代码让我尽快掌握,说心里话本人真心不喜欢java的这种项目方式,各种配置各种xml文件简直头都大了,下面就将我遇到的其中一个我认为是坑的地方整理出来,希望能 ...
- Hibernate总结--MyEclipse的小bug
今天笔者在写一个用S2SH的程序的时候,出现了下面的错误: org.springframework.beans.factory.BeanCreationException: Error creatin ...
- iOS自定义NavigationBar
日常开发中少不了用到UINavigationController,但是很多情况都要自定义NavigationBar.依稀记得自己刚开始也踩了好多坑,凑今天有空,就把想到的写下来.有时间了,考虑再把自定 ...
- HIV T2
甲学者将HIV病毒的遗传物质彻底水解后得到A.B.C三种化合物,乙学者将组成T2噬菌体的遗传物质彻底水解后得到了A.B.D三种化合物.你认为C.D两种化合物分别指的是 A.尿嘧啶.胸腺嘧啶 B.胸腺嘧 ...
- RSS 订阅
<?xml version="1.0"?><%@ Page Language="C#" AutoEventWireup="true& ...
- sql简易的MRP资源分析
写了个简易的MRP根据传进来的数据,进行上下级的判断,父表,子表 构思: 3张变量表,第一张用来存传进来的成品,这边对表做了循环就是成品是一样一样进去的,取成品表的第一行,将数据做父表和子表关联,取出 ...
- background-size 设置背景图片的大小
background-size 设置背景图片的大小,以长度值或百分比显示,还可以通过cover和contain来对图片进行伸缩. 语法: background-size: auto | <长度值 ...