3次元配列における積分値の計算方法について教えてください.
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
3次元配列において,各行列の各要素での積分値の計算方法について教えていただきたいです.
例えば,
以下3次元配列Y(3×5×2),(データ点の間隔は0.1として)において、各行列の要素を積分して求める方法はありますか?
Y (:,:,1)=[1 2 3 4 5;
6 7 8 9 10;
11 12 13 14 15;]
Y (:,:,2)=[2 4 6 8 10;
12 14 16 18 20;
22 24 26 28 30;]
よろしくお願いします.
PS.現在は配列の各要素にアクセスして,台形則による積分trapzを用いて計算しようとしています.
0 commentaires
Réponse acceptée
Hernia Baby
le 14 Fév 2022
配列の形をうまく変更してやってみましょう。
データを用意します。
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,[])
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur 数値積分と微分 dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!