Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


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

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 ]
Curious

Posts: 1,992
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$1@newscl01ah.mathworks.com>...
> 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:

<<http://www.mathworks.com/help/matlab/ref/bsxfun.html>>

or

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]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.