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

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)
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

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 Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기

태그

질문:

2015년 3월 2일

댓글:

2015년 3월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by