将Tj = reshape(Tj, LL, jx, jy);转化为(LL,nj,nj,zks,jx,jy)的维度
时间: 2023-07-27 17:17:28 浏览: 165
要将 `Tj` 转换为 `(LL, nj, nj, zks, jx, jy)` 的维度,需要重新组织代码的循环结构。具体实现如下:
```
[a1, b1] = meshgrid(1:jx, 1:jy);
JSX = a1*gj-r0;
JSY = b1*gj;
SLX = ZK(:,1);
SLY = ZK(:,2);
SLX = repmat(SLX, 1, jx*jy);
SLY = repmat(SLY, 1, jx*jy);
r = sqrt((SLX-JSX(:)').^2 + (SLY-JSY(:)').^2);
rr = reshape(r, [], 1);
Xt = repmat(JSX(:)'-SLX, nj*LL, 1);
z = (0:nj)*dz;
z = repmat(z', 1, jx*jy);
z = reshape(z, [], 1);
a = (2*(1:nj)-3)*dz*0.5;
b = (2*(1:nj)-1)*dz*0.5;
a = repmat(a', 1, jx*jy);
b = repmat(b', 1, jx*jy);
a = reshape(a, [], 1);
b = reshape(b, [], 1);
Tj = zeros(LL, nj, nj, zks, jx, jy);
for i_zks = 1:zks
for i_nj = 1:nj
for j_nj = 1:nj
if (j_nj == 1)
zj = 1;
elseif (j_nj == nj)
zj = H-1;
else
zj = (j_nj-1)*dz;
end
zj = repmat(zj, 1, jx*jy);
ZJ = repmat(j_nj, LL, jx*jy);
Z1 = rr.^2 + (z-zj(:)').^2;
Z2 = rr.^2 + (z+zj(:)').^2;
exp1 = exp(v*Xt*0.5 / Rap);
exp2 = exp(v*Xt*0.5 / Iap);
sqrt1 = sqrt(Z1)*0.5 / Rap;
sqrt2 = sqrt(Z2)*0.5 / Iap;
erfc1 = erfc((sqrt(Z1) - v * t).*0.5 ./ sqrt(Rap*t));
erfc2 = erfc((sqrt(Z1) + v * t).*0.5 ./ sqrt(Rap*t));
erfc3 = erfc((sqrt(Z2) - v * t).*0.5 ./ sqrt(Iap*t));
erfc4 = erfc((sqrt(Z2) + v * t).*0.5 ./ sqrt(Iap*t));
aa = trapz(x, 0.25*exp1.*exp(-v*sqrt1).*erfc1./sqrt(Z1))/(2 * 3.1415926*Rlamd);
ab = trapz(x, 0.25*exp1.*exp(v*sqrt1).*erfc2./sqrt(Z1))/(2 * 3.1415926*Rlamd);
ac = trapz(x, 0.25*exp2.*exp(-v*sqrt2).*erfc3./sqrt(Z2))/(2 * 3.1415926*Ilamd);
ad = trapz(x, 0.25*exp2.*exp(v*sqrt2).*erfc4./sqrt(Z2))/(2 * 3.1415926*Ilamd);
Tj(:, i_nj, j_nj, i_zks, :, :) = reshape(aa + ab - ac - ad, LL, jx, jy);
end
end
end
Tj = permute(Tj, [1, 2, 3, 4, 6, 5]);
Tj = reshape(Tj, LL, nj, nj, zks, jx, jy);
```
这样,我们就可以将 `Tj` 转换为 `(LL, nj, nj, zks, jx, jy)` 的维度了。
阅读全文