shuffle_orderby

버전 1.0.0.0 (2.72 KB) 작성자: Sara Silva
Two functions: shuffles vectors or matrices, orders according to a predefined order.
다운로드 수: 5.1K
업데이트 날짜: 2003/2/20

라이선스 보기

SHUFFLE Shuffles vectors or matrices.
% SHUFFLE(X) shuffles the elements of a vector or matrix X.
%
% SHUFFLE(X,DIM) shuffles along the dimension DIM.
%
% [Y,I] = SHUFFLE(X) also returns an index matrix I. If X is
% a vector, then Y = X(I). If X is an m-by-n matrix, then
% for j = 1:n, Y(:,j) = X(I(:,j),j); end
%
% Input arguments:
% X - the vector or matrix to shuffle (array)
% DIM - the dimension along which to shuffle (integer)
% Output arguments:
% Y - the vector or matrix with the elements shuffled (array)
% I - the index matrix with the shuffle order (array)
%
% Examples:
% X = [10 25 30 40]
% [Y,I] = SHUFFLE(X)
% Y = 30 25 10 40
% I = 3 2 1 4
%
% X = [10 25 ; 3.2 4.1 ; 102 600]
% [Y,I] = SHUFFLE(X)
% Y = 3.2000 600.0000
% 10.0000 25.0000
% 102.0000 4.1000
% I = 2 3
% 1 1
% 3 2
%
% X = [10 25 50 ; 3.2 4.1 5.5 ; 102 600 455 ; 0.03 0.34 0.01]
% DIM = 1
% [Y,I] = SHUFFLE(X,DIM)
% Y = 10.0000 25.0000 50.0000
% 0.0300 0.3400 0.0100
% 102.0000 600.0000 455.0000
% 3.2000 4.1000 5.5000
% I = 1 4 3 2
%
% X = [10 25 50 ; 3.2 4.1 5.5 ; 102 600 455 ; 0.03 0.34 0.01]
% DIM = 2
% [Y,I] = SHUFFLE(X,DIM)
% Y = 10.0000 50.0000 25.0000
% 3.2000 5.5000 4.1000
% 102.0000 455.0000 600.0000
% 0.0300 0.0100 0.3400
% I = 1 3 2
%
% See also ORDERBY
%
% Created: Sara Silva (sara@itqb.unl.pt) - 2002.11.02

ORDERBY Orders vectors and matrices according to a predefined order.
% ORDERBY(X,I) orders the elements of a vector or matrix X
% according to the index matrix I.
%
% ORDERBY(X,I,DIM) orders along the dimension DIM.
%
% If X is a vector, then Y = X(I). If X is an m-by-n matrix, then
% for j = 1:n, Y(:,j) = X(I(:,j),j); end
%
% Input arguments:
% X - the vector or matrix to order (array)
% I - the index matrix with the ordering to apply (array)
% DIM - the dimension along which to order (integer)
% Output arguments:
% Y - the ordered vector or matrix (array)
%
% Examples:
% X = [10 25 30 40]
% I = [3 2 1 4]
% Y = ORDERBY(X,I)
% Y = 30 25 10 40
%
% X = [10 25 ; 3.2 4.1 ; 102 600]
% I = [2 3 ; 1 1 ; 3 2]
% Y = ORDERBY(X,I)
% Y = 3.2000 600.0000
% 10.0000 25.0000
% 102.0000 4.1000
%
% X = [10 25 50 ; 3.2 4.1 5.5 ; 102 600 455 ; 0.03 0.34 0.01]
% I = [1 4 3 2]
% DIM = 1
% Y = ORDERBY(X,I,DIM)
% Y = 10.0000 25.0000 50.0000
% 0.0300 0.3400 0.0100
% 102.0000 600.0000 455.0000
% 3.2000 4.1000 5.5000
%
% X = [10 25 50 ; 3.2 4.1 5.5 ; 102 600 455 ; 0.03 0.34 0.01]
% I = [1 3 2]
% DIM = 2
% Y = ORDERBY(X,I,DIM)
% Y = 10.0000 50.0000 25.0000
% 3.2000 5.5000 4.1000
% 102.0000 455.0000 600.0000
% 0.0300 0.0100 0.3400
%
% See also SHUFFLE
%
% Created: Sara Silva (sara@itqb.unl.pt) - 2002.11.02

인용 양식

Sara Silva (2024). shuffle_orderby (https://www.mathworks.com/matlabcentral/fileexchange/3029-shuffle_orderby), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R10
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
도움

줌: KNMCluster

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
버전 게시됨 릴리스 정보
1.0.0.0