使用线性方程组 (MATLAB)

问题描述

我有 10 个元素,它们的序列号和 x、y、z 坐标在它们的初始和最终 位置:分别是data0和data1。

我打算按如下方式计算应变:

  1. 对于 data0 中的每个元素,我将搜索最接近它的 3 个元素以及四个元素中的每一个 最近元素 (i,j,k,l),x 方向的位移 ui,uj,uk,ul; vi,vj,vk,vl 在 y 方向;并且z方向的wi,wj,wk,wl都计算出来了

  2. 为每4个元素集创建联立方程以获得a0、a1、a2; b0,b1,b2; c0,c1,c2
    "-[1,xi,yi,zi;1,xj,yj,zj;1,xk,yk,zk;1,xl,yl,zl] * [a0,a1,a2,a3] = [ui,ul] -[1,zl] * [b0,b2,b3] = [vi,vl] -[1,zl] * [c0,c2,c3] = [wi,wl]"

  3. 最后,对于每个元素,使用下面代码的计算微应变部分中的方程计算以下应变。

我尝试创建以下代码,但我的联立方程循环结构不佳

data0 = [1,46.15,29.55,4.36; 
2,56.19,34.22,5.33;
3,39.01,33.28,7.27; 
4,29.51,37.41,5.89;
5,65.51,37.97,5.04;
6,50.78,47.22,3.25; 
7,72.69,47.58,4.34; 
8,30.07,48.18,5.62; 
9,41.34,50.11,3.91;
10,61.13,52.16,2.22]                                                                                                                                                                                                                                  
%Extract element number and store element_number
Element_No1=data0(:,1);
X1=data0(:,2);
Y1=data0(:,3);
Z1=data0(:,4);
EUC_disT= data0(:,5);

data1= [1,46.83,30,4.69;
2,56.84,35.49,6.51;
3,39.39,33.56,7.11;
4,29.74,38.16,5.87;
5,64.5,38.55,5.61;
6,50.74,47.57,3.22;
7,71.88,47.8,4.47;
8,29.72,48.2,5.59;
9,41.13,50.23,3.88;
10,60.61,52.4,2.29]

Element_No2=data1(:,1);
X2=data1(:,2);
Y2=data1(:,3);
Z2=data1(:,4);
%Dx= data1(:,5);
%Dy= data1(:,6);
%Dz= data1(:,7);

%Check matrix size           
[m,n]=size(data0);
[p,o]=size(data1);

%count the number of data points
Q0 = numel(data0(:,1));
Q1 = numel(data1(:,1));
q1 = [1:Q1]';

%create matrix of distance difference with zeros
disT_DIFF = zeros(Q0,Q1);

%Calculate the eucledean distsnce difference between each element and others
for j=1:m
for i=1:m
disT_DIFF(j,i) = abs((data0(j,5)-data0(i,5)));
disT_DIFF(disT_DIFF == 0) = NaN;
end 
end

%add the element number to the calculated distance difference 
disT_DIFF = horzcat(disT_DIFF,q1);


%Get the closest 3 element counterpart and store them in EUCL_disT
[r,s]=size(disT_DIFF);
A = [disT_DIFF(:,1),disT_DIFF(:,(Q0+1))];
SA = size(A);
NA = zeros(SA);
EUCL_disT = [];

for i= 1:s-1
%generate matrix for each column of disT_DIFF and Attach element number to each generated column
NA = [disT_DIFF(:,i),(Q0+1))];
%sort each generated column 
S_NA= sortrows(NA);
%take out the 3 closest element
T= [S_NA(1:3,1:2)]; %3 here indicate number of elements to display 
EUCL_disT = [EUCL_disT,T];
end


%Attach other element properties (x,y,z) to matched particles ID

%Isolate the 3 closest particle number and leave out the calculated distance
y0= EUCL_disT(:,2:2:end);

[r,s]=size(y0);
TOG = [];

for i= 1:s
%generate matrix for each column of disT_DIFF and Attach element number to each generated column 
%take out the 3 closest element
q=ismember(data0(:,y0(:,'rows');
z=find(q);
Close_Elements =data0(z,1:4);
TOG = [TOG,Close_Elements];
end


ALL_VAR = zeros(Q0,21);

[p,t]=size(TOG);
[g,h]=size(data0);
[q,r]=size(data1);

for i= 1:t
for ii= 1:h
for iii= 1:r
A1 =[1,data0(1,2),3),4);
1,TOG(1,TOG(2,TOG(3,4)]; 
        
A2 =[1,4)]; 

A3 =[1,4)]; 


B1 = [(data0(1,2)-data1(1,2));
(data0(2,2)-data1(2,2));
(data0(3,2)-data1(3,2));   
(data0(4,2)-data1(4,2))];
        
B2 = [(data0(1,3)-data1(1,3));
(data0(2,3)-data1(2,3));
(data0(3,3)-data1(3,3));
(data0(4,3)-data1(4,3))];
        
B3 = [(data0(1,4)-data1(1,4));
(data0(2,4)-data1(2,4));
(data0(3,4)-data1(3,4));
(data0(4,4)-data1(4,4))];

a = linsolve(A1,B1);
b = linsolve(A2,B2);
c = linsolve(A3,B3);

Const = [a,b,c];
end
end
end
%%%%%Difference between initial and final particle position
Du = X2 - X1;
Dv= y2 - y1;
Dw= z2 - z1;
%%%Difference between each close particle and the particle under consideration
Dx= x2nd -x1;
Dy= x3rd-x1;
Dz= x4th-x1;

%Calculate micro strain - update du,dv,dw,dx,dy,dz to ALL_VARIABLES
a1 = du/dx ;
b2 = dv/dy;
c3 = dw/dz;

Ex = a1;
Ey = b2;
Ez = c3;

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)