Effacer les filtres
Effacer les filtres

3次元でCell毎の平均値を求める

3 vues (au cours des 30 derniers jours)
Saito
Saito le 16 Mar 2020
Réponse apportée : Kenta le 17 Mar 2020
今日は。
今、124X40001のファイルが10あるデータ(124x40001x10)を持っています。これを各セルごとに平均値(124x40001x1)で求めたいのですがどうしたら良いですか?

Réponse acceptée

Kenta
Kenta le 17 Mar 2020
clear;clc
C=cell(10,1);
for i=1:10
% C{i}=randi(100,[124 40001]);
C{i}=ones(124, 40001).*i;
end
meanC = cellfun(@(x) mean(x(:)), C) ;
こんにちは、セルである変数Cの中に10個の変数があって、それぞれのサイズが124 * 40001ということで正しいですか?
その場合であれば、cellfunを使って上のようにすればできます。
また、「平均値(124x40001x1)で求めたい」ということは、10個の数字を使って平均を出す過程を124*40001回行いたいということでしょうか?
その場合は、
clear;clc
C=cell(10,1);
for i=1:10
% C{i}=randi(100,[124 40001]);
C{i}=ones(124, 40001).*i;
end
C_cat=cat(3,C{:});
mean_C=mean(C_cat,3);
としてください。確認しやすいようにones関数を使っていますが、乱数で見たい場合は、コメントで書いているrandiのほうで試してみてください。よろしくお願いいたします。

Plus de réponses (0)

Catégories

En savoir plus sur String Parsing dans Help Center et File Exchange

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!