From: DSPtree on 21 Jun 2010 04:39 Could someone help me out with the code for Vec(.) operation for multidimensional array.(eg: 4-D) Normally eg: A=[1 2 3; 4 5 6] vec(A)=[1 2 3 4 5 6]' that we can find using A(:), and so for $-D how does it come using a 'for loop' Thanks and Regards
From: Matt J on 21 Jun 2010 09:40 A(:) is applicable to all arrays, regardless of their dimension.
From: Steven Lord on 22 Jun 2010 14:15 "DSPtree" <paulscot45(a)yahoo.com> wrote in message news:1664873194.2231.1277124011336.JavaMail.root(a)gallium.mathforum.org... > Could someone help me out with the code for > > Vec(.) operation for multidimensional array.(eg: 4-D) > > Normally > eg: A=[1 2 3; 4 5 6] vec(A)=[1 2 3 4 5 6]' > > that we can find using A(:), Not quite; remember that MATLAB is column-major. If A is [1 2 3;4 5 6] then A(:) should be [1; 4; 2; 5; 3; 6]. To obtain [1; 2; 3; 4; 5; 6] you would need to transpose A first, or do something like reshape(A.', [], 1). > and so for $-D how does it come using a 'for loop' You can use A(:) or RESHAPE for N-D arrays perfectly well -- but you may need to use PERMUTE instead of using TRANSPOSE. -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ To contact Technical Support use the Contact Us link on http://www.mathworks.com
From: us on 22 Jun 2010 15:12 DSPtree <paulscot45(a)yahoo.com> wrote in message <1664873194.2231.1277124011336.JavaMail.root(a)gallium.mathforum.org>... > Could someone help me out with the code for > > Vec(.) operation for multidimensional array.(eg: 4-D) > > Normally > eg: A=[1 2 3; 4 5 6] vec(A)=[1 2 3 4 5 6]' > > that we can find using A(:), > > and so for $-D how does it come using a 'for loop' > > Thanks and Regards a hint: help permute; % eg, v=[1 2 3; 4 5 6]; r=permute(v,[2,1]); r=r(:) us
|
Pages: 1 Prev: Slider of an edit box Next: integration of a vector of functions |