Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Adding point by point using a cell matrix
Replies: 9   Last Post: Jun 14, 2010 11:10 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
ms

Posts: 61
Registered: 11/6/06
Re: Adding point by point using a cell matrix
Posted: Jun 13, 2010 10:55 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On Jun 10, 11:08 am, "sscnekro " <stiahni.m...@zoznam.sk> wrote:
> Hi ms, I am sorry I probably do not understand what you need. I am afraid that my posts have confused you even more.
>
> You said, your cell array is 4 x 3 with each element containing 150 x 1 double. Like e.g. a = cell(4,3); for ii =  1:(size(a,1) * size(a,2)); a{ii} = rand(150,1); end
>
> Suppose it is named "a" and is loaded to workspace. If you paste these two lines to your command window, is this what you wanted?
>
> a = arrayfun(@(col) vertcat(a{:,col}), 1:size(a,2) ,'Unif',false)
> a = cellfun(@mean, a, 'Unif',false)
>
> Otherwise, try to rethink your question under this posts. Start perhaps a new post and be brief and specific. To me the "point by point" mean was not clear at all. You may also re-post the other questions. Many readers are ready to help, but the questions need to be clear. Don't give up!


Thank you for the response, but that still did not work...I will keep
using the for loop until I get this down.
I used what you supplied, but still only ended up with a 1x3 cell
array in the end (with a single value in each...not a 150x1 point-by-
point mean
a = cell(4,3); for ii = 1:(size(a,1) * size(a,2)); a{ii} =
rand(150,1); end%this give me what I expect for a 4x3 cell filled with
150x1 doubles in each
b = arrayfun(@(col) vertcat(a{:,col}), 1:size(a,2) ,'Unif',false)%this
gives a 4,3 cell, with 600x1 doubles in each....not sure here
c = cellfun(@mean, b, 'Unif',false)%the gives a 1x3 cell, with a
single value in each cell. I am looking for a 150x1 double in each
cell at this endpoint.

Thanks so much for taking the time to help!



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.