配列の形をうまく変更してやってみましょう。
データを用意します。
x = randi(10,3,3,20);
x(:,:,1)
reshape によって 3×3×20 を 9×20 の配列へ変更します
[s1,s2,s3] = size(x);
x_1 = reshape(x,s1*s2,s3,1)
横方向に積分します
x_2 = trapz(x_1,2);
reshapeで形を整えます
x_int = reshape(x_2,s1,[])
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!