The Math Forum

Search All of the Math Forum:

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

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

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

Topic: Multiplying each colum of my matrix by a constant
Replies: 13   Last Post: Jun 15, 2013 3:54 AM

Advanced Search

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

Posts: 9,850
Registered: 6/7/07
Re: Multiplying each colum of my matrix by a constant
Posted: Jun 12, 2013 11:08 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On 6/12/2013 9:47 AM, Wanderson wrote:

>> > > If the object is speed in an inner loop, then for the 3x3 case the
>> > original version of writing out the three explicit multiplies may
>> well > be the most efficacious route. For higher dimensions it gets
>> klunky > certainly but for as few as three it's not so bad.

>> > > --
>> Thanks again dpb,
>> In fact, my matrices dimensions vary inside my program rsrs.
>> I start with an 3x3 matrix and they will growing as (2k+1) x (2k+1)
>> dimension.
>> I'll try the repmat idea, this function seems to be very usefull to
>> many things, I should learn more about it.

> BTW[2] rsrs
> I just implemented the repmat solution in my code, but it is slower than
> the bsxfun() option.


I'm not terribly surprised--if you'll look, you'll find that repmat() is
not builtin as one might expect but just an m-file implementation.
bsxfun() is builtin

So, since you've got a variable-sized case, I'm guessing the best
implementation (other than mex-file) will be to use the loop after all.

Again, double-check the File Exchange for a replacement bxsfun() -- it
does seem to me like somebody (Bruno maybe?) posted one there that is


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

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.