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

 Accepted Answer

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 Comments

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.

Sign in to comment.

More Answers (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 Comment

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.

Sign in to comment.

Categories

Find more on Deep Learning Toolbox in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!