这个是只是用行变换将非严格占优矩阵通过行变换转换为严格占有矩阵。

伪代码如下:

Input matrix:A

Output:

If A can transform into a dominance with our method,we can get the dominance.

Else output’Cannot transform the matrix into dominance’

Variable:

Set a matrix record with the size [row_of_matrix,3]

Record[row_length_matrix,3]  %This matrix is for record A’s situation.

% Record[1:,1] first volumn stands for this row of A should be put which row

% Record[1:,2] second volumn stands for whether this row satisfy the necessity of transform into a dominance.If yes,set 1;otherwise 0.

% Record[1:,3] third volumn stands for which initial row belong to.

Flag% this variable is to record whether the matrix A can transform into a dominance.

% If yes,Flag = 1;

% otherwise Flag = 0

% beneath code is to test whether the matrix can transform into a dominance

% and record the situation of every row.

for i = 1:size_of_matrix

Test every row(Record);

If test_row’s Record[1:,2] == 0

then break and output ’Cannot transform the matrix into dominance’

Flag = 0;

end

end

% If Flag = 1,we use row exchangement to transform A into dominance

If Flag = 1

Row_exchangment by record.

for i = 1:row-1

for j = 1:row

if record(j,1) == i         %exchange line if flag = 1,which

%means it can be transformed into dominance

exchange A(i,:) and A(record(j,3),:);

exchange record(j,:) and record(i,:);

break;

end

end

end

Display A;

end

具体实现代码如下:

% Project 1
% SMIE   name:ChenYu   class:1202   nunmber:12353032
% Change nondorminant to dorminant matrix
% this method is adapted for the matrix which can be changed to dorminant
% matrix only using row exchangement
% Input :A matrix
% Output:A matrix which maybe dorminant
function method1(A)
[row,volumn] = size(A);
record = ones(volumn,3);                 %use this matrix to record everyline situation
flag   = 1;                              %first volumn record if the matrix can change to
for i = 1:row                            %dominance,which row the row will

�long.Second volumn record
    every_line                = A(i,:);  %whether the matrix satisfy the necessity

%that everydominance
    record(i,3)               = i;       %third volumn record the rowth
    [record(i,1),record(i,2)] = which_row(every_line);
    if  record(i,2)           == 0
        disp('This Matrix cannot change to dorminant matrix by row exchange.');
        flag                  = 0;
        break;
    end
end
if flag == 1
    for i = 1:row-1
        for j = 1:row
            if record(j,1) == i         %exchange line if flag = 1,which means it can be transformed
                b                = A(i,:);             %into dorminance
                A(i,:)           = A(record(j,3),:);
                A(record(j,3),:) = b;
                temp             = record(j,:);
                record(j,:)      = record(i,:);
                record(i,:)      = temp;
                break;
            end
        end
    end
    disp(A);
end

调用函数:

% function judge_row:
% this function is to judge whether the line is a line of dorminance and
% return which row shuold this line stand
% Input : vector(a row of the matrix)
% Output:if(the line is dorminant) return flag = 1;
%                             else return flag = 0.
function [row,flag] = which_row(a)
n = length(a);
max  = a(1);
flag = 0;
row  = 1;
for i = 2:n
    if max < a(i)          %fing the max value of the line
       max = a(i);         %it's easy for us to know that if the max value is
       row = i;            %larger than the rest of all sum
    end                    %than the line is dorminance
end
and = 0;
for i = 1:n
   if i ~= row             %compare maxvalue and rest sum
        and = and + a(i);
    end
end
if a(row) >= and
    flag = 1;
end

Matlab之将非严格占优矩阵化为严格占优矩阵相关推荐

  1. 如何将一个矩阵化为行阶梯形矩阵

    2016-03-29尾巴线性代数 有同学反映上一课过于冷冰冰,都是一些不带证明的公式.如果线性代数所有公式都要证明的话,线性代数的难度会上好几个量级,有的公式的证明是特别特别难的.还有一个,虽然我们需 ...

  2. matlab把向量转化为矩阵,MATLAB小函数:将列向量转化为0-1矩阵

    MATLAB小函数:将列向量转化为0-1矩阵 将列向量转化为0-1矩阵,例如 A = 1 2 1 5 3 4 1 4 3 转换为: B = 1 0 0 0 0 0 1 0 0 0 1 0 0 0 0 ...

  3. MATLAB基础操作,矩阵乘法、数组矩阵索引、最大最小运算符、零矩阵/随机矩阵/单位矩阵的生成、log函数、Inf和NaN的含义,语句过长用连接符换行、逻辑运算符以及区别

    提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 文章目录 前言 一.矩阵相乘 二.矩阵生成 1.直接输入 2.单位矩阵 3.全零矩阵 2.全一矩阵 2.随机矩阵 三.矩阵操作 四.矩 ...

  4. 如何将矩阵化为约旦标准型_【解题方法】矩阵初等变换的应用

    [本文为了赚点知乎盐值而写, 供各位同学一笑 :P] 本文将介绍并总结矩阵初等变换的一系列的解题应用包括,内容全部整理自本人本科期间的学习笔,对于正在学习高等代数的同学解题应该很有用. 本文主要内容 ...

  5. matlab矩阵定义、矩阵元素引用、矩阵操作

    矩阵定义 直接输入法 A=[1 2 3;4 5 6;7 8 9] 矩阵用方括号 "[ ]" 括起 矩阵同一行中的元素之间用 空格 或 逗号 分隔 矩阵行与行之间用 分号 分开 直接 ...

  6. 矩阵化为最简型矩阵JAVA语言实现――线性代数

    目录 文章目录 前言 一.输入矩阵的信息 二.矩阵的初始处理 三.矩阵的进一步处理 四.显示最终结果 五.代码使用过程 六.整体代码 总结 文章目录 文章目录 前言 一.输入矩阵的信息 二.矩阵的初始 ...

  7. matlab riccati法 临界转速,利用传递矩阵法和Riccati传递矩阵法分析转子临界转速...

    利用传递矩阵法和Riccati传递矩阵法分析转子临界转速 利用传递矩阵法和Riccati传递矩阵法分析转子临界转速 一. 所需求解转子参数 将转子简化为如下所示: 三个盘的参数为: 另,阶梯轴的三段轴 ...

  8. Matlab学习笔记——矩阵求幂和矩阵指数

    写在这里的初衷,一是备忘,二是希望得到高人指点,三是希望能遇到志同道合的朋友. 目录 矩阵求幂和矩阵指数 矩阵求幂和矩阵指数 利用MATLAB对矩阵求幂可以很容易地得到结果,例如: 矩阵求幂 元素对元 ...

  9. matlab中predictor怎么填,在MATLAB中求解非線性有限元

    我嘗試在MATLAB中求解帶有節點熱源的四面體有限元的熱擴散問題,這個節點取決於解矢量.非線性方程系統如下:在MATLAB中求解非線性有限元 乙U」 + A U = Q(T) 與B是熱capactiy ...

最新文章

  1. 关于Jdk7与Jdk8对Collections进行分组的区别
  2. java main 参数传递参数_Java千问:Java语言如何给main方法传递参数?
  3. Flink实时计算性能分析
  4. 30个数据可视化小技巧(文末赠书)
  5. QT中图表类QChart之各种缩放/平移
  6. 我的内核学习笔记7:Intel LPC驱动lpc_ich分析
  7. JMeter使用总结
  8. uglifyjs报错 webpack_vue使用uglifyjs-webpack-plugin后打包报错
  9. setjmp 与 longjmp
  10. 虚拟软件VMware workstation安装
  11. charles浏览器抓包https_十分钟学会Charles抓包(iOS的http/https请求)
  12. C++/面试 - 四种类型转换(cast)的关键字 详解 及 代码
  13. dedecms channel php,DedeCMS在{dede:channel}标签前加序列号
  14. 数据仓库-事实表和维度表的设计
  15. 全国大学计算机硕士专业排名,计算机考研院校排名:中国大学计算机学科排行榜...
  16. 5. Longest Palindromic Substring
  17. mysql 双活_Mysql双活方案
  18. mac 安装软件报错
  19. 基于java(springboot)校园新闻管理系统源码(java毕业设计)
  20. 企业信息化系统ERP篇

热门文章

  1. python小游戏——反弹小球代码开源
  2. 零基础小白java培训学习指南
  3. SAP 批次管理(分割评估)
  4. 如何做APP界面设计
  5. 【论文分享】GNN+小样本文本分类方法:Meta-GNN: On Few-shot Node Classification in Graph Meta-learning
  6. 【工程配置】基于arm-linux-gnueabihf-g++ build boost C++ library
  7. 昆山到苏州公交乘坐终极攻略-实践归来
  8. 计算机管理磁盘管理无法创建GPT,如何创建GPT磁盘|在电脑中建立GPT磁盘模式的方法...
  9. 计算机应用基础2010试题及答案,全国2010年10月高等教育自学考试计算机应用基础试题...
  10. 计算机主机启动不了系统安装系统安装软件,开不了机怎么用u盘重装系统