i want to make random size of my datasample.output must give random size array. As i am very new in matlab. please help.

 採用された回答

Guillaume
Guillaume 2015 年 3 月 2 日
編集済み: Guillaume 2015 年 3 月 2 日
More explanation in the question would be helpful. Possibly, this is what you want:
pickfrom = 'ATCG';
howmany = 20;
pickvalues = pickfrom(randi(numel(pickfrom), 1, howmany))
That is use randi to select a random set of indices that give you which value to pick from your data set.

6 件のコメント

Tonmoy saha
Tonmoy saha 2015 年 3 月 2 日
編集済み: Tonmoy saha 2015 年 3 月 2 日
thanks a lot for your valuable answer. actually i want random size samples from that datasample. suppose if the datasample is TCACCAAAATCACAGGTATG. than i want samples like CACCAA, TCACAGG,.. like that. these sample must be randomly pick and also may have different size .
It's the same principle, use randi to pick the location of your sample:
sample = 'TCACCAAAATCACAGGTATG';
subsamplelength = 6;
subsamplestart = randi(numel(sample)-subsamplelength+1);
subsample = sample(subsamplestart : subsamplestart+subsamplelength-1)
Tonmoy saha
Tonmoy saha 2015 年 3 月 2 日
編集済み: Guillaume 2015 年 3 月 2 日
its work for me. And i change this code little bit. But i have another problem. hope you will solve it. Thanks again sir.
sample = 'TCACCAAAATCACAGGTATG';
subsamplelength = floor(5+(10-5).*rand(1,1));
subsamplestart = randi(numel(sample)-subsamplelength+1);
subsample = sample(subsamplestart : subsamplestart+subsamplelength-1)
instead of fix my subsample to 6 i use this code. but i want random no.s of subsample not just one.
subsamplelength = randi([5 10]);
would be more efficient.
Why can't you create a loop whose upper bound is that random number of subsamples. Again, you can use randi to choose it randomly. Use the above code in the loop.
thank you sir. you help me a lot. Actually i am doing a project using matlab. If you don't mind can i contact you further.
You'll get a lot more help by just posting questions on this forum. There's a lot of people here who are willing to help.

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

その他の回答 (1 件)

you want a random size sample? Like this, perhaps:
DATA = 'ATCG'
K = randi([10 20],1) % random number between 10 and 20
Y = datasample(DATA,K)

1 件のコメント

Tonmoy saha
Tonmoy saha 2015 年 3 月 2 日
編集済み: Tonmoy saha 2015 年 3 月 2 日
actually i want random size samples from that datasample. suppose if the datasample is TCACCAAAATCACAGGTATG. than i want samples like CACCAA, TCACAGG,.. like that. these sample must be randomly pick and also may have different size.

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

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by