چرخاندن ( بر عکس کردن ) یک ماتریس در متلب
راه1:
reverse matrix: x=[1 3 8 20 100 121] -> y=[121 100 20 8 3 1]
x=[1 3 8 20 100 121];
r = randperm(length(x));
t1 = x(r);
[t2,t3] = sort(r,'descend');
y = t1(t3);
راه2:
x=[1 3 8 20 100 121];y=x(end:-1:1)
راه 3:
fliplr - Flip matrix left to right
Syntax
B = fliplr(A)
Description
B = fliplr(A)
B = fliplr(A) returns A with columns flipped in the left-right direction, that is, about a vertical axis.
If A is a row vector, then fliplr(A) returns a vector of the same length with the order of its elements reversed. If A is a column vector, then fliplr(A) simply returns A.
Examples
If A is the 3-by-2 matrix,
A =
1 4
2 5
3 6
then fliplr(A) produces
4 1
5 2
6 3
If A is a row vector,
A =
1 3 5 7 9
then fliplr(A) produces
9 7 5 3 1
Limitations
The array being operated on cannot have more than two dimensions. This limitation exists because the axis upon which to flip a multidimensional array would be undefined.
See Also
به نقل از:
http://www.mathworks.co.uk/help/techdoc/ref/fliplr.html
