Selecting random points from data file

Hi, is there any algorethim to select random points from a large data file. Lets say I want to select data after every 20 values. x = [1:0.1:1000]
If I want y = select every 10th 20th or 50th point of x
Thanks Amb

4 件のコメント

per isakson
per isakson 2014 年 12 月 12 日
編集済み: per isakson 2014 年 12 月 12 日
Try
>> M = 1:100;
M(20:20:100)
ans =
20 40 60 80 100
but that's hardly random.
Azzi Abdelmalek
Azzi Abdelmalek 2014 年 12 月 12 日
The question is not clear, "10th 20th or 50th point of x"
amberly hadden
amberly hadden 2014 年 12 月 12 日
Sorry if its not clear I mean to write pick every 10th or 20th point of x.
Amb
amberly hadden
amberly hadden 2014 年 12 月 12 日
sorry random means scanig rando area up down lesft right

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

 採用された回答

Mohammad Abouali
Mohammad Abouali 2014 年 12 月 12 日

0 投票

x = [1:0.1:1000];
x_every10th=x(10:10:numel(x));
x_every20th=x(20:20:numel(x));
x_every50th=x(50:50:numel(x));
You get the idea.

4 件のコメント

amberly hadden
amberly hadden 2014 年 12 月 12 日
Thanks but its out put is 1*2 matix. Quit differnt from what I want
here is an example lets say x = a b c (3*2000 Matrix) I want to pick every 10th value of x means I need to output x = a10 b10 c10:a20 b20 c20 and so on for means pick every 10th value
Mohammad Abouali
Mohammad Abouali 2014 年 12 月 12 日
So you are changing the question. In your question x is a row vector now it is matrix. and you want every 10th, 20th, ... row
then change it to this:
x_every10th=x(10:10:size(x,1),:);
x_every20th=x(20:20:size(x,1),:);
x_every50th=x(50:50:size(x,1),:);
amberly hadden
amberly hadden 2014 年 12 月 12 日
yeah I have a 307000*3 matrix
want to select every 10th row. Is there any wany to data from random rows lets say for region I'm more interested I can select every 20th point for region Im not much interested slect every 50th and close to my sourse select every 10th point.
Thanks much apriciated
amberly hadden
amberly hadden 2014 年 12 月 12 日
another thing I want out put in 3 columns its just producing one column.

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

その他の回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 12 月 12 日

0 投票

x = [1:0.1:1000];
n=randi(5)*10
out=x(n:n:end)

1 件のコメント

amberly hadden
amberly hadden 2014 年 12 月 12 日
randi is good option but how would I aviod repeation
Thanks

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

カテゴリ

ヘルプ センター および File ExchangeInterpolation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by