Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: -extract 120X9 matrix from 1000X9 matrix randomly
Date: Tue, 9 Feb 2010 17:23:04 +0000 (UTC)
Organization: Universit&#228;tsSpital Z&#252;rich
Lines: 50
Message-ID: <hks5lo$r1o$1@fred.mathworks.com>
References: <hks11k$ti$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1265736184 27704 172.30.248.37 (9 Feb 2010 17:23:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 9 Feb 2010 17:23:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 11
Xref: news.mathworks.com comp.soft-sys.matlab:605817


"muk " <hungocan@hotmail.com> wrote in message <hks11k$ti$1@fred.mathworks.com>...
> Hello all,
> 
> Now, i have 1000X9 matrix which is quality parameters. And, i want to extract 120X9 matris randomly from 1000x9 matrix.
> How can i do that?
> 
> Sincerely, 

as others have said: it is not quite clear what you mean by a randomly selected submatrix...
assuming you want to carve out a randomly selected sub-block from your main mat,...

one of the solutions

% the data
     m=ceil(10*rand(5,4));     % <- main mat
     sr=2;     % <- #rows of submat
     sc=3;     % <- #cols of submat
% the engine
     [nr,nc]=size(m);
     [x,y]=meshgrid(1:nr:sc*nr,0:sr-1);
     seg=x+y;     % <- SEG: indices into block at top/left
     off=nr*(nc-sc+1)-sr;     % <- OFF: max movement of SEG
     roff=ceil(off*rand);     % <- select random OFF
% the result
     disp(m);
     disp(m(seg+0));     % <- top/left submat
     disp(m(seg+off));     % <- last possible submat
     disp(roff);     % <- random SEG
     disp(m(seg+roff));     % <- randomly selected submat
%{
% the mat
     2     2     6     6
     7     1     9     2
     6     5     1     6
     1     9    10     1
     1     7     2     8
% top/left
     2     2     6
     7     1     9
% last possible block given SR/SC
     9    10     1
     7     2     8
% random OFF
     7
% submat at random OFF
     5     1     6
     9    10     1
%}

us