Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.


Pag Max
Posts:
13
Registered:
5/16/11


repmat, reshape, bsxfun
Posted:
Jan 23, 2012 12:28 AM


"James Tursa" wrote in message <jfhog2$laf$1@newscl01ah.mathworks.com>... > "Pag Max" wrote in message <jfca39$r4g$1@newscl01ah.mathworks.com>... > > Is there a smarter or shorter way to do this than what I have done? (Of course withot loop!!). I am thinking there is something repetitive in my solution > > c is tiled in third dimension as many times as elements in b and then each tile is scaled by corresponding element in b. > > > > c=[1 2 3;4 5 6]; > > b=[1 2 3 4 5]; > > a=bsxfun(@times,repmat(c,[1 1 numel(b)]),reshape(b,[1 1 numel(b)])); > > Why repmat the c matrix? E.g., > > a=bsxfun(@times,c,reshape(b,[1 1 numel(b)])); > > TMW seems to be dropping posts, so I will risk repeating an earlier post. My MTIMESX can also do this calculation, but will likely only benefit if the array sizes are large. What are the actual array sizes you are working with? > > James Tursa
Thanks I get it. Yes this post appeared much after I submitted. So did not check any responses. I understand repmat was a repeatation. Yes I am dealing with very large array sizes. Will like to know if MTIMESX can be a smarter solution.



