From: Giga Babs on
Hya
Is there a matlab function for changing the position of 2 rows in a matrix ??,
for example I have A= [1,8,6 ; 7,8,9 ; 6,4,5 ; 1,2,3]

And I want to have B= [1,8,6 ; 1,2,3 ; 6,4,5 ; 7,8,9] I permute the row 2 and 4 from the matrix A....

Thank you in advance
From: Walter Roberson on
Giga Babs wrote:
> Hya Is there a matlab function for changing the position of 2 rows in a
> matrix ??,
> for example I have A= [1,8,6 ; 7,8,9 ; 6,4,5 ; 1,2,3]
>
> And I want to have B= [1,8,6 ; 1,2,3 ; 6,4,5 ; 7,8,9] I permute the row
> 2 and 4 from the matrix A....

B = A([1 4 3 2], :);

or:

B = A;
B([2 4],:) = A([4 2],:);
From: Giga Babs on
Walter Roberson <roberson(a)hushmail.com> wrote in message <hqp5m1$735$2(a)canopus.cc.umanitoba.ca>...
> Giga Babs wrote:
> > Hya Is there a matlab function for changing the position of 2 rows in a
> > matrix ??,
> > for example I have A= [1,8,6 ; 7,8,9 ; 6,4,5 ; 1,2,3]
> >
> > And I want to have B= [1,8,6 ; 1,2,3 ; 6,4,5 ; 7,8,9] I permute the row
> > 2 and 4 from the matrix A....
>
> B = A([1 4 3 2], :);
>
> or:
>
> B = A;
> B([2 4],:) = A([4 2],:);

Thank you Walter