Prev: Can you stop and continue execution, or check the progress of the program?
Next: query on matlab
From: Ashok1288 kumar on 26 Jul 2010 08:43 when I use sum() function to obtain the sum of columns of a matrix I am getting an error! Here is my commands " >> a={1,2,3;4,5,6;7,8,9} a = [1] [2] [3] [4] [5] [6] [7] [8] [9] >> sum(a); ??? Undefined function or method 'sum' for input arguments of type 'cell'. " Will you please help me with this since i am a newbie to Matlab. Thanks in advance.
From: us on 26 Jul 2010 08:49 "Ashok1288 kumar" <asok1288(a)gmail.com> wrote in message <i2jvso$2br$1(a)fred.mathworks.com>... > when I use sum() function to obtain the sum of columns of a matrix I am getting an error! > > Here is my commands > " > >> a={1,2,3;4,5,6;7,8,9} > > a = > > [1] [2] [3] > [4] [5] [6] > [7] [8] [9] > > >> sum(a); > ??? Undefined function or method 'sum' for input arguments of type 'cell'. > " > > Will you please help me with this since i am a newbie to Matlab. > > Thanks in advance. one of the solutions a={1,2,3;4,5,6;7,8,9} r=sum(cell2mat(a)) % r = 12 15 18 us
From: Dev on 26 Jul 2010 08:55 do this : a=[1,2,3;4,5,6;7,8,9] sum works on array of type double. "Ashok1288 kumar" <asok1288(a)gmail.com> wrote in message <i2jvso$2br$1(a)fred.mathworks.com>... > when I use sum() function to obtain the sum of columns of a matrix I am getting an error! > > Here is my commands > " > >> a={1,2,3;4,5,6;7,8,9} > > a = > > [1] [2] [3] > [4] [5] [6] > [7] [8] [9] > > >> sum(a); > ??? Undefined function or method 'sum' for input arguments of type 'cell'. > " > > Will you please help me with this since i am a newbie to Matlab. > > Thanks in advance.
From: Ashok1288 kumar on 26 Jul 2010 09:06 thanks what is the difference in using [] and {} in fact both denote array? Thanks
From: Steven_Lord on 26 Jul 2010 09:10 "Ashok1288 kumar" <asok1288(a)gmail.com> wrote in message news:i2k17t$di$1(a)fred.mathworks.com... > thanks what is the difference in using [] and {} in fact both denote > array? An array constructed using [] is a numeric array (by default, a double array.) http://www.mathworks.com/access/helpdesk/help/techdoc/learn_matlab/f2-12841.html http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_prog/f2-12135.html Each element in a numeric array must be the same data type as the other elements in the array, and each element is a scalar (one number only.) An array constructed using {} is a cell array. http://www.mathworks.com/access/helpdesk/help/techdoc/learn_matlab/f4-2137.html#f4-2245 http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_prog/br04bw6-98.html Each cell in a cell array can contain a numeric array of a different size, and each one can be of a different data type. [The _cells_ that make up the cell array are all scalar and are all cell arrays; the _contents_ of the cells may differ in size and type.] -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ To contact Technical Support use the Contact Us link on http://www.mathworks.com
|
Next
|
Last
Pages: 1 2 Prev: Can you stop and continue execution, or check the progress of the program? Next: query on matlab |