From: Banasri Sarma on 27 Mar 2010 05:18 How to write the code for the following multidimensional thing: for s=1:n; A(:,:,s)=[1 2 3]; B(:,:,s)=[10 20 30] then result should come as C(:,:,s)=[11 12 13;21 22 23;31 32 33] the Third dimension is very important
From: Bruno Luong on 27 Mar 2010 06:58 "Banasri Sarma" <banasris(a)gmail.com> wrote in message <hokigc$s56$1(a)fred.mathworks.com>... > How to write the code for the following multidimensional thing: > for s=1:n; > A(:,:,s)=[1 2 3]; B(:,:,s)=[10 20 30] > then result should come as > C(:,:,s)=[11 12 13;21 22 23;31 32 33] > the Third dimension is very important Please take a look of functions BSXFUN and PERMUTE Bruno
From: Walter Roberson on 27 Mar 2010 13:10 Banasri Sarma wrote: > How to write the code for the following multidimensional thing: > for s=1:n; > A(:,:,s)=[1 2 3]; B(:,:,s)=[10 20 30] > then result should come as > C(:,:,s)=[11 12 13;21 22 23;31 32 33] > the Third dimension is very important see the documentation for bsxfun. It only works with scalars, vectors, and 2D data, but when you loop around like that, you are really only working with vectors.
From: Doug Schwarz on 27 Mar 2010 13:27 In article <hole5h$9vo$2(a)canopus.cc.umanitoba.ca>, Walter Roberson <roberson(a)hushmail.com> wrote: > Banasri Sarma wrote: > > How to write the code for the following multidimensional thing: > > for s=1:n; > > A(:,:,s)=[1 2 3]; B(:,:,s)=[10 20 30] > > then result should come as > > C(:,:,s)=[11 12 13;21 22 23;31 32 33] > > the Third dimension is very important > > see the documentation for bsxfun. It only works with scalars, vectors, > and 2D data, but when you loop around like that, you are really only > working with vectors. Are you saying that bsxfun only works with 1- or 2-D inputs? That's not right -- it works with inputs of any dimension. I don't know what the OP is asking or I'd offer up a solution. -- Doug Schwarz dmschwarz&ieee,org Make obvious changes to get real email address.
From: Walter Roberson on 27 Mar 2010 14:07 Doug Schwarz wrote: > Are you saying that bsxfun only works with 1- or 2-D inputs? That's not > right -- it works with inputs of any dimension. Hmmm, multiple dimensions does seem to be what is documented, but a few days ago I received an error message from bsxfun in 2008b specifically saying that the arrays had to be at most 2D. Perhaps that only applied to some specific usages.
|
Next
|
Last
Pages: 1 2 Prev: Sell Crystal rock tshirts women,laguna beach tshirts Next: active noise cancellation |