shake

버전 5.0 (2.16 KB) 작성자: Jos (10584)
Randomize a matrix along one dimension
다운로드 수: 4K
업데이트 날짜: 2019/2/7

라이선스 보기

shake - Randomize a matrix along a specific dimension
Y = shake(X) randomizes the order of the elements in each column of the
2D matrix. For N-D matrices it randomizes along the first non-singleton
dimension.

shake(X, DIM) randomizes along the dimension DIM.

[Y, I, J] = shake(X) returns indices so that Y = X(I) and X = Y(J).

Example:
A = [1 2 3 ; 4 5 6 ; 7 8 9 ; 10 11 12] ; % see <SLM> on the FEX ...
B = shake(A, 2) % -> each row is shaked randomly
% 3 2 1
% 6 4 5
% 7 8 9
% 11 10 12%
C = sort(B, 2) % -> equals A!

For vectors V, shake(V) is similar to V(randperm(numel(V)).

The function of shake can be thought of as holding a matrix and shake
in a particular direction (dimension), so that elements are getting
shuffled within that direction only.

인용 양식

Jos (10584) (2026). shake (https://kr.mathworks.com/matlabcentral/fileexchange/10067-shake), MATLAB Central File Exchange. 검색 날짜: .

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

도움 준 파일: randone1, RANDSWAP, Permute a grouped vector

버전 게시됨 릴리스 정보
5.0

updated for newer ML releases, updated algorithm

1.0.0.0

fixed error for scalar inputs