我正在尝试创建一个Abeles 矩阵形式主义模型来分析一些实验数据 - 我附上了一个 wiki 链接以供参考,以便您可以看到我试图实现的目标。
我的问题的症结在于我无法将四组矩阵相乘,例如:A[1]*B[1]*C[1]*D[1], A[2]*B[2]*C[2]*D[2], ..., A[n]*B[n]*C[n]*D[n]
. 然后我需要将结果存储为它们自己的单独矩阵 - 每个矩阵代表相应的动量传递值Qmin:Qstep:Qmax
。
另外,当我尝试执行最后一步时;R = abs((ABCD(2,1)./ABCD(1,1)).^2)
我最终得到一个值,而不是R
每个值的Q
值。
由于代码的大小,简单的 for 循环不是一个现实的选择。
my 'test' code is:
%import data fid = fopen('run_22208_09.dat');
%A = textscan(fid,'%f%f%f',270,'headerlines',0,'delimiter',',');
NQ = size(A{1,1});
NQ = NQ(1);
Qmin = A{1,1}(1);
Qmax = A{1,1}(NQ);
Qstep = A{1,1}(2) - A{1,1}(1);
fclose('all');
s0 = 2e-6;
s1 = 10e-6;
s2 = 6e-6;
s3 = 4e-6;
s4 = 8e-6;
sn = 12e-6;
r1 = 2;
r2 = 10;
r3 = 3;
r4 = 7;
t1 = 10;
t2 = 45;
t3 = 5;
t4 = 20;
Q=Qmin:Qstep:Qmax;
k = 2.*Q;
k1 = (((k).^2) - 4.*pi.*(s1 - s0)).^0.5;
k2 = (((k).^2) - 4.*pi.*(s2 - s0)).^0.5;
k3 = (((k).^2) - 4.*pi.*(s3 - s0)).^0.5;
k4 = (((k).^2) - 4.*pi.*(s4 - s0)).^0.5;
kn = (((k).^2) - 4.*pi.*(sn - s0)).^0.5;
layer1 = ((k1 - k2)./(k1 + k2)).*(exp(-2.*k1.*k2.*(r1.^2)));
beta1 = (sqrt(-1)).*k1.*t1;
layer2 = ((k2 - k3)./(k2 + k3)).*(exp(-2.*k2.*k3.*(r2.^2)));
beta2 = (sqrt(-1)).*k2.*t2;
layer3 = ((k3 - k4)./(k3 + k4)).*(exp(-2.*k3.*k4.*(r3.^2)));
beta3 = (sqrt(-1)).*k3.*t3;
layer4 = ((k4 - kn)./(k4 + kn)).*(exp(-2.*k4.*kn.*(r4.^2)));
beta4 = (sqrt(-1)).*k4.*t4;
%general matrix
C1 = [exp(beta1),layer1.*(exp(beta1));layer1.*exp(-beta1),exp(-beta1)]
C2 = [exp(beta2),layer2.*(exp(beta2));layer2.*exp(-beta2),exp(-beta2)];
C3 = [exp(beta3),layer3.*(exp(beta3));layer3.*exp(-beta3),exp(-beta3)];
C4 = [exp(beta4),layer4.*(exp(beta4));layer4.*exp(-beta4),exp(-beta4)];
% CA = bsxfun(@times,C1,C2)
% CB = bsxfun(@times,CA,C3);
% C = bsxfun(@times,CB,C4)
% R = abs((C(2,1)./C(1,1)).^2)