Randomly Shuffle X and Y

5 ビュー (過去 30 日間)
REN Jain
REN Jain 2020 年 10 月 21 日
コメント済み: KSSV 2020 年 10 月 21 日
Hello,
I have 2 arrays,
x which is a 4d array of size 200*300*3*2188,
I have 2188 images (200*300*3) stack up together in x.
and i have y which is the labels for these images of size 2188*3 , 3 is the no of classes.
So I want to randomly shuffel x and y in the same manner so that the labels remain same.
For ex -
x=['a','b','c','d','e']
y=[1,2,3,4,5]
after shuffle
x=['d','a','e',b','c']
y=[4,1,5,2,3]
Thank You

回答 (1 件)

KSSV
KSSV 2020 年 10 月 21 日
Read about randperm.
y = 1:5 ;
n = length(y) ;
idx = randperm(n) ;
y(idx)
  2 件のコメント
REN Jain
REN Jain 2020 年 10 月 21 日
I also want to shuffel x in the same manner that y is shuffle.
KSSV
KSSV 2020 年 10 月 21 日
Follow the same procedure. Just use:
x(idx)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeImages についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by