cell配列の加算平均をしたい

Cell配列の加算平均をしたいです。
testdataは1×2のcell配列ですが、実際には1×10程度になるかと思います。
Cell配列の中には、8×1001配列が格納されています。
具体的には、それぞれのcellの1〜8列目をそれぞれ抜き出し平均し、
最終的に8×1001配列にしたい思っております。
よろしくお願いします。

1 Comment

yuta
yuta on 14 Feb 2023
採用遅くなりすみません。
このような方法があるのですね!
ありがとうございます!

Sign in to comment.

 Accepted Answer

Atsushi Ueno
Atsushi Ueno on 10 Feb 2023
cell 配列から行列に変換し、更に2次元⇒3次元に変換すれば「各頁の要素の平均」となり分かり易いと思います
websave('testdata','https://jp.mathworks.com/matlabcentral/answers/uploaded_files/1291545/testdata.mat');
load('testdata.mat');
testdata_mat = reshape(cell2mat(testdata),8,1001,[]); % cell 配列から行列に変換、2次元⇒3次元に変換
result = mean(testdata_mat,3)
result = 8×1001
0.1001 0.1148 0.1295 0.1443 0.1590 0.1737 0.1885 0.2032 0.2179 0.2325 0.2472 0.2618 0.2764 0.2909 0.3054 0.3199 0.3343 0.3486 0.3629 0.3770 0.3912 0.4052 0.4191 0.4330 0.4467 0.4604 0.4739 0.4874 0.5007 0.5139 -0.1138 -0.0952 -0.0767 -0.0583 -0.0399 -0.0216 -0.0033 0.0148 0.0329 0.0508 0.0687 0.0864 0.1041 0.1216 0.1389 0.1562 0.1733 0.1902 0.2070 0.2237 0.2402 0.2565 0.2727 0.2887 0.3045 0.3202 0.3356 0.3509 0.3659 0.3808 0.4123 0.4249 0.4374 0.4498 0.4622 0.4745 0.4868 0.4990 0.5111 0.5232 0.5351 0.5470 0.5587 0.5704 0.5820 0.5934 0.6047 0.6159 0.6270 0.6380 0.6488 0.6595 0.6700 0.6804 0.6906 0.7008 0.7107 0.7205 0.7301 0.7396 0.0510 0.0587 0.0663 0.0739 0.0816 0.0891 0.0967 0.1042 0.1117 0.1191 0.1265 0.1339 0.1412 0.1484 0.1556 0.1627 0.1698 0.1769 0.1838 0.1907 0.1976 0.2043 0.2110 0.2176 0.2242 0.2306 0.2370 0.2434 0.2496 0.2557 0.3358 0.3460 0.3563 0.3665 0.3768 0.3871 0.3974 0.4076 0.4179 0.4281 0.4383 0.4485 0.4587 0.4689 0.4790 0.4890 0.4990 0.5090 0.5189 0.5288 0.5386 0.5484 0.5580 0.5676 0.5771 0.5866 0.5960 0.6052 0.6144 0.6235 0.0652 0.0843 0.1033 0.1221 0.1408 0.1594 0.1778 0.1961 0.2142 0.2322 0.2499 0.2675 0.2849 0.3021 0.3191 0.3358 0.3524 0.3687 0.3848 0.4007 0.4163 0.4317 0.4468 0.4617 0.4763 0.4907 0.5048 0.5186 0.5322 0.5454 -0.0652 -0.0620 -0.0588 -0.0556 -0.0523 -0.0491 -0.0458 -0.0425 -0.0391 -0.0358 -0.0324 -0.0290 -0.0256 -0.0222 -0.0187 -0.0152 -0.0118 -0.0083 -0.0048 -0.0012 0.0023 0.0058 0.0094 0.0130 0.0166 0.0202 0.0238 0.0274 0.0311 0.0347 0.0577 0.0597 0.0618 0.0639 0.0660 0.0682 0.0703 0.0725 0.0746 0.0768 0.0790 0.0812 0.0834 0.0856 0.0878 0.0901 0.0923 0.0946 0.0968 0.0991 0.1013 0.1036 0.1059 0.1082 0.1105 0.1127 0.1150 0.1173 0.1196 0.1219

More Answers (0)

Products

Release

R2022a

Asked:

on 10 Feb 2023

Commented:

on 14 Feb 2023

Community Treasure Hunt

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

Start Hunting!