总体思路
我一直在从事线性代数项目,该项目的目的是测试给定的向量集(矩阵)是否线性dependent/independent。为此,下一个程序将接收一个名为值的矩阵(用户输入/ MxN),并首先通过该标准(该部分没有问题),然后向量是线性依赖的,则必须测试内部向量之间是否存在某些LI / LD子集,为此开始迭代行的排列并为其确定条件,如果这导致LI子集,则必须绘制向量以及向量形成的空间。即使初始矩阵的大小为MxN,通常也希望该矩阵为2或3列(R2或R3)。
问题
在第二遍中,一旦系统被标记为线性相关,则系统将图形重叠在相同的窗口中,所需的输出将是进行第一遍,如果系统是LD,则显示初始图,然后以单独的方式开始绘制图窗口形成的置换矩阵的图。
NewMatrix遍历原始“值”矩阵,并继续形成行/向量的排列以再次检查条件(它确实在同一窗口中)。请注意,初始矩阵“值”是由用户定义的,应该已经在显示的代码的起点输入了。
代码
RangS=rank(R) //LI or ld criterion
[r, c] = size(value)
if (rank(value))==r
set(handles.text3,'String',('System>LI'));
figure(3);
hold on;
z = zeros(size(value, 1), 1);
quiver3(z, z, z, value(:, 1), value(:, 2), z, 0);
grid on
view(45, 45);
s=sum(value);
quiver3(0,0,0,s(1),s(2),0,'r');
points=[X' Y'];
else
set(handles.text3,'String',('System>LD'));
figure(3); //this graph should be done apart
hold on;
z = zeros(size(value, 1), 1);
quiver3(z, z, z, value(:, 1), value(:, 2), z, 0);
grid on
view(45, 45);
points=[X' Y'];
for jj = 1:size(value,1)-1 //here starts permuting vectors>credits to MikeLimaOscar
for kk = jj+1:size(value,1)
NewMatrix= value([jj,kk],:)
F=rref(NewMatrix);
RangS=rank(R) //the same criterion applied to the permutated matrices
[r, c] = size(NewMatrix)
if (rank(NewMatrix))==r
set(handles.text3,'String',('Subsystem :LI'));
figure(3); there should be one graph for every permutated matrix
hold on;
z = zeros(size(NewMatrix, 1), 1);
quiver3(z, z, z, NewMatrix(:, 1), NewMatrix(:, 2), z, 0);
grid on
view(45, 45);
s=sum(NewMatrix);
quiver3(0,0,0,s(1),s(2),0,'r');
points=[X' Y'];
else
set(handles.text3,'String',('Subsystem:LD'));
figure(3);
hold on;
z = zeros(size(NewMatrix, 1), 1);
quiver3(z, z, z, NewMatrix(:, 1), NewMatrix(:, 2), z, 0);
grid on
view(45, 45);
points=[X' Y'];
end
end
end
end
答案 0 :(得分:1)
figure(3)
]上。每个窗口的特定索引
Permutation(jj) |Permutation 1 | Permutation 2 | Permutation 3
____________________________________________________________________
|[1]submatrix 1 | [4]submatrix 1 |[6]submatrix 1
submatrix(kk) |[2]submatrix 2 | [5]submatrix 2 |[7]submatrix 2
|[3]submatrix 3 | |[8]submatrix 3
| | |[9]submatrix 4
____________________________________________________________________
Last index | 3 | 5 | 9
____________________________________________________________________
括号中的索引将用作图形参数
Permutation 1
,只需使用子矩阵索引kk
,index_1 = kk
Permutation 2
,使用子矩阵索引kk
和置换Last index
中的1
子矩阵index_2 = Last index(Permutation 1) + kk
Permutation 3
,使用子矩阵索引kk
和置换Last index
中的2
子矩阵index_3 = Last index(Permutation 2) + kk
泛化,是第一个排列的一部分,第n个排列中的索引是
index_n = Last index(Permutation n-1)) + kk
对于给定total of submatrices
的给定问题Permutation jj
可以计算为
total(Permutation jj) = numel(jj+1:size(value,1))
请仔细阅读评论
% Check if the entire matrix is linear independent or not
if LI
% Linear independent
% Plot the graph in window #1
figure(1)
else
% Linear dependent
% Plot the graph in window #1
figure(1)
% Starting index for next Permutation
Last_index = 0;
% Figure() argument initialization
index = 0;
% Permutation begins here
for jj = 1:size(value,1)-1
% submatrices for a given permutation jj begins here
for kk = jj+1:size(value,1)
% Check if submatrix is linear independent or not
if submatrix(kk) from permutation (jj) is LI
% Linear independent
% Plot the graph in window #index
index = Last_index + kk
figure(index)
else
% Linear dependent
% Plot the graph in window #index
index = Last_index + kk
figure(index)
end
% End of checking if submatrix is linear independent or not
end
% Update last index for the next permutation starting index
Last_index = Last_index + numel(jj+1:size(value,1))
% End of submatrices for a given permutation jj
end
% End of Permutation
end
% End of checking if the entire matrix is linear independent or not