Prev: rounding particle value using PSO
Next: Contourf
From: Sam on 22 Mar 2010 05:43 Hi all, I need to write a code for adding two vectors of different length, e.g. x=[1 9 8] and y=[2 0 4 9], treating the row vectors as integers. Any help will be appreciated.
From: Jan Simon on 22 Mar 2010 05:50 Dear Sam! > I need to write a code for adding two vectors of different length, e.g. x=[1 9 8] and y=[2 0 4 9], treating the row vectors as integers. Any help will be appreciated. But what do you want or expect as result??? What does "add" mean, if the vectors have different sizes?! Kind regards, Jan
From: us on 22 Mar 2010 05:57 "Sam " <sam.watts60(a)ntlworld.com> wrote in message <ho7e37$mnn$1(a)fred.mathworks.com>... > Hi all, > > I need to write a code for adding two vectors of different length, e.g. x=[1 9 8] and y=[2 0 4 9], treating the row vectors as integers. Any help will be appreciated. show CSSM an small example of an input and an expected output... us
From: Walter Roberson on 22 Mar 2010 05:58 Sam wrote: > I need to write a code for adding two vectors of different length, e.g. > x=[1 9 8] and y=[2 0 4 9], treating the row vectors as integers. Any > help will be appreciated. What kind of result are you expecting? If you are expecting every combination of additions, 1+2, 9+4, 8+0 and so on, then see bsxfun(). If you are expecting element-wise addition, then is the implication that the shorter vector is to be extended with zeros before doing the additions?
From: Sam on 22 Mar 2010 05:59
"Jan Simon" <matlab.THIS_YEAR(a)nMINUSsimon.de> wrote in message <ho7egc$sh0$1(a)fred.mathworks.com>... > Dear Sam! > > > I need to write a code for adding two vectors of different length, e.g. x=[1 9 8] and y=[2 0 4 9], treating the row vectors as integers. Any help will be appreciated. > > But what do you want or expect as result??? > What does "add" mean, if the vectors have different sizes?! > > Kind regards, Jan Thanks for answering Jan. I need to add zeros at the front of the smaller number so that I can add the two up. For example x would become [0 1 9 8]. Also when they add up I need the number to extend as they must all be single digits. [9] + [8] must become [1 7] not [17]. Sam |