我有一個AxBxC數組,其中AXB指向我採樣的一個字段的各個網格(如座標),C對應於下面的圖層。現在我想通過將它與2D矩陣相乘來計算某些活動對這些單獨點的影響。 例如Matlab:使用二維數組的三維陣列的子集
x=5; %x-Dimensions of the sampled area
y=5; %y-Dimensions of the sampled area
z=3; %z-number of layers sampled
Area= zeros(x,y,z);
AreaN= zeros(x,y,z);
現在我想乘以X * Y與給定的點的每一層:
AppA=[0.4,0.4,0.2;0.4,0.5,0.1;0.1,0.2,0.7];
我想:
for i=1:x
for j=1:y
AreaN(i,j,:)= AppA*Area(i,j,:);
end
end
Unfotunately我得到的錯誤:
Error using *
Inputs must be 2-D, or at least one input must be scalar.
To compute elementwise TIMES, use TIMES (.*) instead.
任何幫助,這是讚賞si我對matlab還不是很熟悉。
是你的'z'長度與'AppA'相同嗎? – Rashid 2014-11-04 07:23:55