0
我正在開發一個scilab程序,以在立方體中平均一個3d矩陣。這主要是完成的,但我想將大小設置爲給定的總和(每個立方體中的體素都加起來一定量),而我每次嘗試添加此功能時都要繼續打破該程序。在scilab中製作3D矩陣平均器?
function totSAR = comptS(Material, SAR, a, b, c, a1, b1, c1, grams)
si=size(SAR);
radius=0;
OK=0;
totwei=0;
totSAR=0;
totpx=0;
while (totwei<=grams*1e-3 && OK==0)
totwei2=totwei;
totSAR2=totSAR;
totpx2=totpx;
totwei=0;
totpx=0;
totSAR1=0;
totSAR=0;
radius=radius+1;
for o=-radius:radius
rado=floor(sqrt(radius^2-o^2));
for m=-rado:rado
radm=floor(sqrt(rado^2-m^2));
for n=-radm:radm
if (a+m >= 1 && a+m <= si(1) && b+n >=1 && b+n <=si(2) && c+o >= 1 && c+o <si(3))
if totwei<=10e-3
totwei=totwei+a1*b1*c1*Material(a+m, b+n, c+o);
if SAR(a+m, b+n, c+o)>0
totpx=totpx+1;
totSAR=totSAR+SAR(a+m, b+n, c+o);
end
end
end
end
end
end
if totSAR==totSAR1
OK=1;
end
end
coefw = (grams*1e-3 - totwei2)/(totwei-totwei2);
totpxs = coefw*(totpx-totpx2);
totSARs = coefw*(totSAR-totSAR2);
totpx;
if totpx>0
totSAR=(totSAR2+totSARs)/(totpx2+totpxs);
end
end
對不起,我是一個新手,並感謝您的幫助!
謝謝,我知道這肯定是一些愚蠢的錯誤。 – AlanGhalan