problem with mean in cell arrays

for k=1:8
cd(phonemes{k});
data=dir('*.pcm');
for i=1:length(data)
fid=fopen(data(i).name,'r');
phone{k}.train_sig{i}=fread(fid,inf,'int16');
phone{k}.train_mfcc{i}=frontend(phone{k}.train_sig{i});%extracting mfcc's
m{k}.e{i}=mean(phone{k}.train_mfcc{i});%each value for m{k}.e{i} is 1x12 array
fclose(fid);
end
v{k}=mean({m{k}.e{:}});%error undefined sum
end
i make this code and now i want to calculate the mean for m{k}.e{:},namely the mean for each m{k}. for all e{} elements !! any ideas ?? i tried v{k} but its wrong..any help??

 採用された回答

Sven
Sven 2012 年 2 月 18 日

0 投票

v{k} = mean([m{k}.e{:}])
The mean() function calculates the mean of an array of numbers, not a cell.
The above should work because you stated that each value for m{k}.e{i} is 1x12. If instead they were column matrices (ie, 12x1), then you couldn't concatenate them horizontally with [], but could instead use
mean(cat(1,m{k}.e{:}))

1 件のコメント

panagiotis
panagiotis 2012 年 2 月 18 日
thx a lot sven! :)

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

質問済み:

2012 年 2 月 18 日

Community Treasure Hunt

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

Start Hunting!

Translated by