MATLAB Answers

# cell mean from each cells

27 views (last 30 days)
Kuang-Yu WANG on 26 Jun 2018
Commented: Walter Roberson on 26 Jun 2018
I need to get the result like this
mean(cellfun(@(x) x(1,4), thething))
mean(cellfun(@(x) x(2,4), thething))
....
mean(cellfun(@(x) x(n,4), thething))
however my cell are
thething = {26*7 double}
{33*7 double}
{100*7 double}
.....{22*7 double}
not all cells have n lines.I need to use the cells that do have datas to calculate the means to form a plot. thanks!
##### 3 CommentsShowHide 2 older comments
Walter Roberson on 26 Jun 2018
Please do not close questions that have an answer.

Sign in to comment.

### Answers (1)

KL on 26 Jun 2018
It doesn't matter how many lines each cell has. Probably you want something like,
C = {rand(50,7),rand(30,7),rand(100,7)}; %example
C_means = cellfun(@mean,C,'uni',0)
##### 0 CommentsShowHide -1 older comments

Sign in to comment.

### Community Treasure Hunt

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

Start Hunting!
{"ft_lang_label":"__label__en","ft_lang_prob":0.8226252,"math_prob":0.6454103,"size":344,"snap":"2021-04-2021-17","text_gpt3_token_len":108,"char_repetition_ratio":0.14411765,"word_repetition_ratio":0.0,"special_character_ratio":0.35174417,"punctuation_ratio":0.18072289,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9521091,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-04-19T04:03:16Z\",\"WARC-Record-ID\":\"<urn:uuid:eb718d5f-6fe2-4f9b-9d64-e991be574b4a>\",\"Content-Length\":\"121409\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:26e7929d-c62d-4379-8122-b7d63dbc0c96>\",\"WARC-Concurrent-To\":\"<urn:uuid:21595f07-a05a-45fd-a83c-e055c959aa16>\",\"WARC-IP-Address\":\"23.197.108.134\",\"WARC-Target-URI\":\"https://ch.mathworks.com/matlabcentral/answers/407447-cell-mean-from-each-cells\",\"WARC-Payload-Digest\":\"sha1:RZTL6AEJMHQBKDV3TM24333OBGCUP6CH\",\"WARC-Block-Digest\":\"sha1:6LJ6T24BUKX4FDMX3E4BSZPEYGRRQD45\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-17/CC-MAIN-2021-17_segments_1618038863420.65_warc_CC-MAIN-20210419015157-20210419045157-00342.warc.gz\"}"}