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: matrix with column-wise increasing values
Replies: 8   Last Post: Aug 8, 2014 5:47 PM

Advanced Search

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

Posts: 2,359
Registered: 12/6/04
Re: matrix with column-wise increasing values
Posted: Aug 7, 2014 3:45 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"manu" wrote in message <ls0iqr$nfr$>...
> Thank you very much.
> Unfortunately, this is approach is a bit too slow.
> I need to work with vector multiplication as I have several millions of iterations and the matrix is also a bit bigger.
> But thank you very much for your thoughts and your work!!!

I don't have MATLAB installed on this computer, so I can't test this out, but it seems to me you should be able to use bsxfun in some clever way. Look at the last example in:



doc bsxfun

Perhaps something like this will work for your example:

A = 1:5;
B = (0:3).';
C = bsxfun(@plus,A,B)

Like I said, I can't test the above, but you should get the idea.
Also, even if it works, I don't know if it will be any faster than an efficient for loop version.
It will depend on the size of your array and the memory you have available.

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.