フィルターのクリア

Standard deviation of multiple cell arrays

12 ビュー (過去 30 日間)
Christoph Thorwartl
Christoph Thorwartl 2021 年 6 月 24 日
コメント済み: Star Strider 2021 年 6 月 24 日
I've figured out how to get the average of multiple cell arrays. M is a 1x19 cell
MEAN = mean(cat(3,M{:}),3)
This works well. Now I want to apply the same for the standard deviation:
SD= std(cat(3,M{:}),3)
However, the following error occurs:
>> SD= std(cat(3,M{:}),3)
Error using var (line 197)
W must be a vector of nonnegative weights, or a scalar 0 or 1.
Error in std (line 59)
y = sqrt(var(varargin{:}));
Could someone help me how to rewrite the code?
Thanks and best regards,
Christoph

採用された回答

Star Strider
Star Strider 2021 年 6 月 24 日
I am not certain what ‘M’ actually is.
Try this —
M = {rand(5),rand(5),rand(5)} % Create 'M'
M = 1×3 cell array
{5×5 double} {5×5 double} {5×5 double}
SD = std(cat(3,M{:}),[],3)
SD = 5×5
0.3347 0.2972 0.2701 0.3528 0.1500 0.3883 0.3171 0.2027 0.1444 0.1855 0.2140 0.4325 0.2838 0.2795 0.3368 0.1092 0.2164 0.0409 0.2087 0.3983 0.1550 0.1595 0.3300 0.0953 0.1421
Supply an empty array [] for the weight argument and it should work.
.
  2 件のコメント
Christoph Thorwartl
Christoph Thorwartl 2021 年 6 月 24 日
Thanks for the quick response. It works perfectly!
Star Strider
Star Strider 2021 年 6 月 24 日
As always, my pleasure!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by