extract numbers from cell array and calculate mean

I have a cell array containing numbers and strings. Can someone help me with a code that can calculate the mean of the numbers in each row?
Mix = {
'U' [4.7506e+05] [5.0141e+05] [5.4067e+05] [ 542976] [5.7124e+05]
[3.9810e+05] [4.4926e+05] 'U' [ 531440] [5.3655e+05] 'O'
[3.0915e+05] [3.6336e+05] [3.7107e+05] [3.8252e+05] [3.3988e+05] [4.3384e+05]
'U' 'U' 'U' 'O' 'U' [3.7107e+05]
'U' [3.7107e+05] 'U' [3.8252e+05] 'U' 'O' }

 採用された回答

Fangjun Jiang
Fangjun Jiang 2018 年 4 月 30 日

1 投票

index=cellfun(@isnumeric,Mix);
Mix(~index)={0};
mean(cell2mat(Mix),2)

2 件のコメント

JB
JB 2018 年 4 月 30 日
Thanks a lot Fangjun, that is perfect
Jan
Jan 2018 年 5 月 1 日
+1. I've overseen that the means are wanted for each row.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeData Type Conversion についてさらに検索

製品

タグ

質問済み:

JB
2018 年 4 月 30 日

コメント済み:

Jan
2018 年 5 月 1 日

Community Treasure Hunt

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

Start Hunting!

Translated by