How to calculate the average of a cell array?
60 ビュー (過去 30 日間)
古いコメントを表示
Hi, I have a cell array like this -
T = {[10, 1, 30], [15, 2, 10], [20, 3, 20]}
I want to calculate the mean of T in a way that the result is a 1x3 double. And the result is,
T = [15, 2, 20]
It means the result should average the values of its position. (10+15+20)/3 = 15
Thank you!!
0 件のコメント
採用された回答
Voss
2023 年 8 月 7 日
T = {[10, 1, 30], [15, 2, 10], [20, 3, 20]}
M = vertcat(T{:})
meanT = mean(M,1)
0 件のコメント
その他の回答 (1 件)
Les Beckham
2023 年 8 月 7 日
T = {[10, 1, 30], [15, 2, 10], [20, 3, 20]}
A = vertcat(T{:}) % make an array from the elements of the cell array by stacking them
m = mean(A) % average the columns
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!