如题:

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实现判断是否能否生成严格对角占优矩阵的更多相关文章

  1. MATLAB高斯混合数据的生成

    MATLAB高斯混合数据的生成 作者:凯鲁嘎吉 - 博客园 http://www.cnblogs.com/kailugaji/ 高斯混合模型的基本原理:聚类——GMM,MATLAB中GMM聚类算法:M ...

  2. matlab中元胞数组(cell)转换为矩阵

    matlab中元胞数组(cell)转换为矩阵. cell转换为矩阵函数为:cell2mat(c),其中c为待转换的元胞数组: 转化之后的矩阵可能不满足我们对矩阵维数的要求,那么也许还需要下面两个函数: ...

  3. MATLAB小函数:将列向量转化为0-1矩阵

    MATLAB小函数:将列向量转化为0-1矩阵 作者:凯鲁嘎吉 - 博客园 http://www.cnblogs.com/kailugaji/ 将列向量转化为0-1矩阵,例如 A = 1 2 1 5 3 ...

  4. 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 ...

  5. 【转载】matlab如何判断一个点是否在多面体内

    转载自:http://www.52souji.net/point-within-a-polyhedron/ 我遇到的一个实际问题是:要在空位区域随机放置一定数量的原子,这些原子在空位区域任何一处存在的 ...

  6. matlab (.m)文件生成 windows 可执行(.exe)文件

    mex -setup:设置 C 语言编译器:(如果本地安装有 visual studio 20xx 集成开发环境,则会自动选择其下的 C/C++ 编译器 ) 将运行时环境(runtime enviro ...

  7. Matlab绘图基础——散点生成三角网(TIN)

    %例一:二维三角网TIN模型的生成 X=rand(10,2)*5; dt=DelaunayTri(X(:,1),X(:,2));       %生成三角网 triplot(dt);hold on;   ...

  8. matlab中randi代替randint生成随机均匀分布信号的用法

    %%新函数  2*randi([0,1],2,1)-1   等价于老函数     2*randint(2,1)-1 函数形式:randi([imin,imax],m,n) 参数解释: [imin,im ...

  9. java学习-zxing生成二维码矩阵的简单例子

    这个例子需要使用google的开源项目zxing的核心jar包 core-3.2.0.jar 可以百度搜索下载jar文件,也可使用maven添加依赖 <dependency> <gr ...

随机推荐

  1. HDU 3038 How Many Answers Are Wrong (并查集)

    How Many Answers Are Wrong Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Ja ...

  2. poj 3378 二维树状数组

    思路:直接用long long 保存会WA.用下高精度加法就行了. #include<map> #include<set> #include<cmath> #inc ...

  3. poj 2029 二维树状数组

    思路:简单树状数组 #include<map> #include<set> #include<cmath> #include<queue> #inclu ...

  4. 【原】 twemproxy ketama一致性hash分析

    转贴请注明原帖位置:http://www.cnblogs.com/basecn/p/4288456.html 测试Twemproxy集群,双主双活 向twemproxy集群做写操作时,发现key的分布 ...

  5. 获取XML数据

    http://www.w3school.com.cn/xml/xml_elements.asp <?xml version="1.0" encoding="gb23 ...

  6. .NET DLL 保护措施详解(二)关于性能的测试

    先说结果: 加了缓存的结果与C#原生代码差异不大了 我对三种方式进行了测试: 第一种,每次调用均动态编译 第二种,缓存编译好的对象 第三种,直接调用原生C#代码 .net dll保护系列 ------ ...

  7. Struts2_概述

  8. 收藏的js学习小例子

    1.js模拟java里的Map function Map(){ var obj = {} ; this.put = function(key , value){ obj[key] = value ; ...

  9. Newtonsoft.Json 基本用法

    Newtonsoft.Json 是.net 开源的一个json格式处理类库 官方网站:http://json.codeplex.com/ 在使用的项目引用Newtonsoft.Json库.平常使用的方 ...

  10. UI2_UITableViewDelete

    // AppDelegate.m // UI2_UITableViewDelete // // Created by zhangxueming on 15/7/14. // Copyright (c) ...