edit-selecting random values

2 ビュー (過去 30 日間)
kash
kash 2012 年 1 月 12 日
I have a 10x10 matrix,i need 3 x10 ,but the corresponging column values must not change
if u r selecting any elememt from ist row that corresponging column values must not change

採用された回答

Andrei Bobrov
Andrei Bobrov 2012 年 1 月 12 日
EDIT [09:13(UTC+4) 13.01.2012]
A = randi(48,10)
s = size(A);
n = [3 10];
q = reshape(1:numel(A),s(1),[]);
rc = s - n + 1;
m = q(1:rc(1),1:rc(2));
I = randperm(numel(m));
p = m(I(1));
out = A(rem(p-1,s(1))+(1:n(1)),ceil(p/s(1))+(0:n(2)-1))
  5 件のコメント
kash
kash 2012 年 1 月 13 日
thanks andrei,i did not get as i desired,ur output is continious 3 rows, but i neeed as distinct values...i.e
for ex first row values
38
10
19
that is i dont need continuous values,please help
Andrei Bobrov
Andrei Bobrov 2012 年 1 月 13 日
two last rows of my code
p = m(I(1:n(1)));
out = A(p,ceil(p(1)/s(1))+(0:n(2)-1))

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

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2012 年 1 月 13 日
It looks to me as if the answer should just be
p = randperm(size(A,1));
out = A(p(1:3),:);
  1 件のコメント
kash
kash 2012 年 1 月 13 日
thanks walter ,this is answer am looking for

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

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by