Mean Value in a variables cell array

5 ビュー (過去 30 日間)
Leonard Haensel
Leonard Haensel 2021 年 5 月 16 日
コメント済み: Leonard Haensel 2021 年 5 月 17 日
Hello everyone,
I am looking for the following problems already almost desperate. The problem is as follows. I have a Cell Array which is structured as follows (see picture) 40 rows x 100 columns. The distance between the data points (each datapoint is a vector with 284 elements) is always 9 fields. However, the starting point varies. I need the mean value for each row (40 mean values in total). Between the single vector values, which I need for the determination of the mean values, there are empty rows ([ ]). Thus, I expect a cell array with 40 rows, each containing 284 values ( mean of the data points (vectors) )
I have already tried any variations (expand with NaN, loops, etc.). With cell2mat I do not get further. Does anyone have an idea ?

採用された回答

Stephen23
Stephen23 2021 年 5 月 16 日
Where C is your cell array:
N = size(C,1);
M = nan(N,1);
for k = 1:N
M(k) = mean([C{k,:}]);
end
  5 件のコメント
Stephen23
Stephen23 2021 年 5 月 17 日
N = size(C,1);
D = cell(N,1);
for k = 1:N
D{k} = mean([C{k,:}],2);
end
Leonard Haensel
Leonard Haensel 2021 年 5 月 17 日
I would like to thank you very much. You have helped me a lot. I will try to formulate my next forum entry precisely enough from the beginning.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by