I want to break my sample like this. Problem with my logic. need help

2 vues (au cours des 30 derniers jours)
Tonmoy saha
Tonmoy saha le 4 Mar 2015
Commenté : Jos (10584) le 7 Mar 2015
suppose my sample is GAATGCT. i take a size say 4. my output will be like this GAAT,AATG,ATGC,TGCT. when it reach the last position it will stop. it tried for loop but instead of getting this kind of output it gives me single char. i think there is a problem with my logic. can anyone help me. subsample='GAATGCT'; for n=subsample(1:(end-4+1)) for i=subsample(1:4) display(i) end end
  3 commentaires
Jan
Jan le 4 Mar 2015
Modifié(e) : Jan le 4 Mar 2015
@Tonmoy: I've formatted your code. "Output like this" is not exact enough to guess, what you want to achieve. Please explain exactly, what the code should do.
Tonmoy saha
Tonmoy saha le 4 Mar 2015
i have some datasample. i have to cut it such a way that it gives me same size of subsample. every time loop counter will increase and gives me same size of subsample starting from the the next char.

Connectez-vous pour commenter.

Réponse acceptée

Jos (10584)
Jos (10584) le 4 Mar 2015
data = 'GAATGCT'
N = 4 ;
for k= 1:numel(data)-N
subsample = data(k:k+N) ;
disp(subsample)
end
  5 commentaires
Tonmoy saha
Tonmoy saha le 4 Mar 2015
Modifié(e) : Tonmoy saha le 4 Mar 2015
i change this code little bit to get my desire output.
data = 'GAATGCT'
N = 4 ;
for k= 1:numel(data)-N+1
subsample = data(k:k+N-1) ;
disp(subsample)
end

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by