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 ...
随机推荐
- Linux公社资料库地址
免费下载地址在 http://linux.linuxidc.com/用户名与密码都是http://www.linuxidc.com
- ASP-----分页功能的实现
WEB 分页功能的实现后端C#代码部分: // 建立Linq 数据库的连接 private MYDateDataContext context = new MYDateDataContext(); / ...
- 转:eclipse技巧之快速生成Override函数
转自: http://www.cnblogs.com/junqilian/archive/2013/03/15/2960277.html 小提示:Eclipse 中快速实现或Override基类或接口 ...
- HTML插入SWF
1.插入透明flash代码 <object classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" codebase=" ...
- sql 了解
char,varchar,nvarchar区别 类型 长度 使用说明 长度说明 char(n) 固定长度 索引效率高 程序里面使用trim去除多余的空白 n 必须是一个介于 1 和 8,000 之间 ...
- VpnService
这段时间项目中使用到了VpnService,整理了一下官方文档的资料 VpnService is a base class for applications to extend and build t ...
- SQL循环
加群学习:457351423 这里有4000多部学习视频,有需要的欢迎进群学习! declare @temp Table ( nf varchar(50), yf varchar(50), sm va ...
- C# 类构造函数赋值里属性与字段赋值注意项
public class Test { public Test(int age) { this.Age=age;//如果这里使用的是this.age=age;那么属性里的判断将不会执行 } priva ...
- UI1_UINavigationController
// // FourthViewController.h // UI1_UINavigationController // // Created by zhangxueming on 15/7/6. ...
- 微信公众号与HTML 5混合模式揭秘2——分享手机相册中照片
本书是分享微信jssdk开发的第二篇. 4.2.1 项目需求 需求说明:实现微信端的手机用户,点击按钮选取1张图片,分享到朋友圈. 4.2.2 需求分解 通过对需求的了解,可以将其分解为: ( ...