as example :
A = [8 9 0]
Perm1 = randperm(length(A));
B= A(:,Perm1);
B_eks=B
[val_sort, id_sort] = sort(Perm1);
A_eks = B_eks(:,id_sort);
i want it for looping, so A_eks(:,:,1) = [8 9 0],;A_eks(:,:,2) = [8 9 0],A_eks(:,:,2) = [8 9 0],A_eks(:,:,4) = [8 9 0], i have try like this:
for i=1:4
Perm1(:,:,i) = randperm(length(A));
B(:,:,i)= A(:,Perm1(:,:,i));
B_eks(:,:,i)=B(:,:,i)
end
for k=1:4
[val_sort, id_sort] = sort(Perm1(:,:,k));
A_eks(:,:,k) = B_eks(:,id_sort);
end
but it didn't work like i want, what should i do ?

6 件のコメント

KSSV
KSSV 2017 年 10 月 25 日
A = [8 9 0]
Perm1 = randperm(length(A));
B= A(:,Perm1);
B_eks=B
[val_sort, id_sort] = sort(Perm1);
A_eks = B_eks(:,id_sort);
This piece of code gives you back A again....why to do? :(
KL
KL 2017 年 10 月 25 日
Maybe your example with just 3 elements (as KSSV says, they are already sorted!) is not sufficient, probably you need to explain your input and expected output better.
KL
KL 2017 年 10 月 25 日
@cvklpstunc: permuted indices are being sorted, which makes the permutation itself redundant. A_eks will all be the same as A.
maharani meidy
maharani meidy 2017 年 10 月 25 日
@KSSV @KL: yes, i need it to be A again, because i use it for extraction from watermarked video. the watermark is apply to every frame, so a_eks needs to be the same with A. is it answer ur question ?
@cvklpstunc : i want my data permutated in random position for it secure. is there easier way for it?
thanks all ^^
KSSV
KSSV 2017 年 10 月 25 日
If you want it to be same..keep it same....why to run all the stuff? Using randperm is good if you want to permute array randomly.
maharani meidy
maharani meidy 2017 年 10 月 25 日
@KSSV : well.. i want it to be more secure than just keep it the same...^^

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

 採用された回答

KL
KL 2017 年 10 月 25 日

0 投票

Change
A_eks(:,:,k) = B_eks(:,id_sort);
to
A_eks(:,:,k) = B_eks(:,id_sort,k);

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

質問済み:

2017 年 10 月 25 日

コメント済み:

2017 年 10 月 25 日

Community Treasure Hunt

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

Start Hunting!

Translated by