From: Judas Magnus on 7 Apr 2010 15:03 http://www.sendspace.com/file/xeorjs Open that in matlab and it will be stored into the workspace I'm suppose to add all the elements in y and give the sum. would it be like sum(y) but i tried that and it doesnt work ?
From: Matt Fig on 7 Apr 2010 15:09 How about just typing in a simple example which represents your problem, rather than asking strangers to trust that you aren't having them download something malicious? A = {1 2 3 4}; % Does your data look like that? sum([A{:}]) % If so.
From: Judas Magnus on 7 Apr 2010 15:34 Sorry it's like this myCell = cell(1,3) myCell{1,1} =[1,4,-10;] myCell{1,2} =[9,5,3,8,9,2,1,0,8,9,3,5,0,7,2,5,1,0,5,9,6,5,1,1,0,2,2,9,4,9,1,7,3,2,0,3,2,7,6,5,5,2,6,9,2,6,8,3,4,6,4,5,6,1,8,4,5,2,5,8,7,3,8,6,1,6,0,3,4,6,7,9,4,6,4,1,8,4,3,5,0,5,9,8,5,3,2,0,0,2,7,3,4,8,1,9,0,2,6,5;] myCell{1,3} = [25,21,35,29,99,69;1,56,62,54,3,94;92,4,45,83,2,91;61,3,9,65,58,100;59,90,21,28,26,63;82,80,66,18,98,65;65,62,31,44,80,56;44,86,83,24,65,96;] "Matt Fig" <spamanon(a)yahoo.com> wrote in message <hpil8l$grh$1(a)fred.mathworks.com>... > How about just typing in a simple example which represents your problem, rather than asking strangers to trust that you aren't having them download something malicious? > > A = {1 2 3 4}; % Does your data look like that? > > sum([A{:}]) % If so.
From: Matt Fig on 7 Apr 2010 15:43 O.k., so now you need to specify whether or not you need some sort of 'grand total', or just the sum of elements in each cell. This is because the SUM function behaves differently for different sizes of inputs. myCell = {magic(4), [1 2 3], [7;8;9], rand(6,7)} % A simple example. sum(cellfun(@(x) sum(x(:)),myCell)) % Grand total over all cellfun(@sum,myCell,'Un',0) % Simple application of SUM for each cell cellfun(@(x) sum(x(:)),myCell) % Grand total over all elements of each cell
|
Pages: 1 Prev: multiply columns by vector Next: overlaying images of different sizes |