1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

MATLAB > 実装 > 二次元arrayを10回シャッフルする

Posted at
動作環境
GeForce GTX 1070 (8GB)
ASRock Z170M Pro4S [Intel Z170chipset]
Ubuntu 16.04 LTS desktop amd64
TensorFlow v1.2.1
cuDNN v5.1 for Linux
CUDA v8.0
Python 3.5.2
IPython 6.0.0 -- An enhanced Interactive Python.
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu)
scipy v0.19.1
geopandas v0.3.0
MATLAB R2017b (Home Edition)

参考

MATLAB > random > 整数の乱数を得る > X = round(rand()*100)
MATLAB > array > サイズを得る > [ len1, len2 ] = size(tri)

code

shuffle_171115.m
% v0.1 Nov. 15, 2017
%    - shuffle 10 times

function shuffle_171115(tri)
    [len1, len2] = size(tri);
    for loop = 1:10
        % get index of [1:N-1]
        pos = round(rand()* (len1 - 2)) + 1;
        % swap
        tri([pos pos+1],:) = tri([pos+1 pos],:)
    end
>> tri = [ 1 1 1; 2 2 2; ];
>> shuffle_171115(tri)

tri =

     2     2     2
     1     1     1


tri =

     1     1     1
     2     2     2
(後略)
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?