Search All of the Math Forum:

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

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

 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

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!

Date Subject Author
6/9/10 ms
6/9/10 sscnekro
6/9/10 sscnekro
6/10/10 ms
6/10/10 ms
6/10/10 sscnekro
6/13/10 ms
6/14/10 sscnekro
6/14/10 sscnekro
6/14/10 Sebo K