MATLAB: I want to break the sample like this. Problem with the logic. need help

matlab function

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

Best Answer

  • data = 'GAATGCT'
    N = 4 ;
    for k= 1:numel(data)-N
    subsample = data(k:k+N) ;