Cody

# Problem 79. DNA N-Gram Distribution

Solution 1329320

Submitted on 6 Nov 2017 by Noriko Hounoki
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
s = 'AACTGAACG'; n = 3; hifreq_correct = 'AAC'; assert(isequal(nGramFrequency(s,n),hifreq_correct))

ap = 1×7 logical array 1 0 0 0 0 1 0 apnum = 2 0 0 0 0 0 0 ap = 1×7 logical array 0 1 0 0 0 0 0 apnum = 2 1 0 0 0 0 0 ap = 1×7 logical array 0 0 1 0 0 0 0 apnum = 2 1 1 0 0 0 0 ap = 1×7 logical array 0 0 0 1 0 0 0 apnum = 2 1 1 1 0 0 0 ap = 1×7 logical array 0 0 0 0 1 0 0 apnum = 2 1 1 1 1 0 0 ap = 1×7 logical array 1 0 0 0 0 1 0 apnum = 2 1 1 1 1 2 0 ap = 1×7 logical array 0 0 0 0 0 0 1 apnum = 2 1 1 1 1 2 1 m = 2 im = 1 hifreq = 'AAC'

2   Pass
s = 'dynamic routing service'; n = 2; hifreq_correct = 'ic'; assert(isequal(nGramFrequency(s,n),hifreq_correct))

ap = 1×22 logical array 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 apnum = 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ap = 1×22 logical array 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 apnum = 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ap = 1×22 logical array 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 apnum = 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ap = 1×22 logical array 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 apnum = 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ap = 1×22 logical array 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 apnum = 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ap = 1×22 logical array 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 apnum = 1 1 1 1 1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ap = 1×22 logical array 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 apnum = 1 1 1 1 1 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ap = 1×22 logical array 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 apnum = 1 1 1 1 1 2 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ap = 1×22 logical array 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 apnum = 1 1 1 1 1 2 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 ap = 1×22 logical array 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 apnum = 1 1 1 1 1 2 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 ap = 1×22 logical array 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 apnum = 1 1 1 1 1 2 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 ap = 1×22 logical array 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 apnum = 1 1 1 1 1 2 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 ap = 1×22 logical array 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 apnum = 1 1 1 1 1 2 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 ap = 1×22 logical array 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 apnum = 1 1 1 1 1 2 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 ap = 1×22 logical array 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 apnum = 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 ap = 1×22 logical array 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 apnum = 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 ap = 1×22 logical array 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 apnum = 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 ap = 1×22 logical array 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 apnum = 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 ap = 1×22 logical array 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 apnum = 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 ap = 1×22 logical array 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 apnum = 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 ap = 1×22 logical array 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 apnum = 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 0 ap = 1×22 logical array 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 apnum = 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 m = 2 im = 6 hifreq = 'ic'

3   Pass
s = 'Your veracity is exceeded by your sagacity.'; n = 5; hifreq_correct = 'acity'; assert(isequal(nGramFrequency(s,n),hifreq_correct))

ap = 1×39 logical array 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 apnum = Columns 1 through 29 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 39 0 0 0 0 0 0 0 0 0 0 ap = 1×39 logical array 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 apnum = Columns 1 through 29 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 39 0 0 0 0 0 0 0 0 0 0 ap = 1×39 logical array 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 apnum = Columns 1 through 29 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 39 0 0 0 0 0 0 0 0 0 0 ap = 1×39 logical array 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 apnum = Columns 1 through 29 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 39 0 0 0 0 0 0 0 0 0 0 ap = 1×39 logical array 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 apnum = Columns 1 through 29 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 39 0 0 0 0 0 0 0 0 0 0 ap = 1×39 logical array 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 apnum = Columns 1 through 29 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 39 0 0 0 0 0 0 0 0 0 0 ap = 1×39 logical array 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 apnum = Columns 1 through 29 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 39 0 0 0 0 0 0 0 0 0 0 ap = 1×39 logical array 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 apnum = Columns 1 through 29 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 39 0 0 0 0 0 0 0 0 0 0 ap = 1×39 logical array 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 apnum = Columns 1 through 29 1 1 1 1 1 1 1 1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 39 0 0 0 0 0 0 0 0 0 0 ap = 1×39 logical array 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 apnum = Columns 1 through 29 1 1 1 1 1 1 1 1 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 39 0 0 0 0 0 0 0 0 0 0 ap = 1×39 logical array 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 apnum = Columns 1 through 29 1 1 1 1 1 1 1 1 2 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 39 0 0 0 0 0 0 0 0 0 0 ap = 1×39 logical array 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 apnum = Columns 1 through 29 1 1 1 1 1 1 1 1 2 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 39 0 0 0 0 0 0 0 0 0 0 ap = 1×39 logical array 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 apnum = Columns 1 through 29 1 1 1 1 1 1 1 1 2 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 39 0 0 0 0 0 0 0 0 0 0 ap = 1×39 logical array 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 apnum = Columns 1 through 29 1 1 1 1 1 1 1 1 2 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 39 0 0 0 0 0 0 0 0 0 0 ap = 1×39 logical array 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 apnum = Columns 1 through 29 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 39 0 0 0 0 0 0 0 0 0 0 ap = 1×39 logical array 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 apnum = Columns 1 through 29 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 39 0 0 0 0 0 0 0 0 0 0 ap = 1×39 logical array 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 apnum = Columns 1 through 29 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 39 0 0 0 0 0 0 0 0 0 0 ap = 1×39 logical array 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 apnum = Columns 1 through 29 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 39 0 0 0 0 0 0 0 0 0 0 ap = 1×39 logical array 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 apnum = Columns 1 through 29 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 Columns 30 through 39 0 0 0 0 0 0 0 0 0 0 ap = 1×39 logical array 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 apnum = Columns 1 through 29 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 Columns 30 through 39 0 0 0 0 0 0 0 0 0 0 ap = 1×39 logical array 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 apnum = Columns 1 through 29 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 ...

4   Pass
s = 'AGCGAAGGAAGGATCACATTTCTCAGGACAAAGGCATTTCACTAATGGTT'; n = 3; hifreq_correct = 'AGG'; assert(isequal(nGramFrequency(s,n),hifreq_correct))

ap = 1×48 logical array Columns 1 through 44 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 45 through 48 0 0 0 0 apnum = Columns 1 through 29 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ap = 1×48 logical array Columns 1 through 44 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 45 through 48 0 0 0 0 apnum = Columns 1 through 29 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ap = 1×48 logical array Columns 1 through 44 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 45 through 48 0 0 0 0 apnum = Columns 1 through 29 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ap = 1×48 logical array Columns 1 through 44 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 45 through 48 0 0 0 0 apnum = Columns 1 through 29 1 1 1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ap = 1×48 logical array Columns 1 through 44 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 45 through 48 0 0 0 0 apnum = Columns 1 through 29 1 1 1 2 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ap = 1×48 logical array Columns 1 through 44 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 Columns 45 through 48 0 0 0 0 apnum = Columns 1 through 29 1 1 1 2 3 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ap = 1×48 logical array Columns 1 through 44 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 45 through 48 0 0 0 0 apnum = Columns 1 through 29 1 1 1 2 3 4 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ap = 1×48 logical array Columns 1 through 44 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 45 through 48 0 0 0 0 apnum = Columns 1 through 29 1 1 1 2 3 4 3 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ap = 1×48 logical array Columns 1 through 44 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 45 through 48 0 0 0 0 apnum = Columns 1 through 29 1 1 1 2 3 4 3 2 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ap = 1×48 logical array Columns 1 through 44 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 Columns 45 through 48 0 0 0 0 apnum = Columns 1 through 29 1 1 1 2 3 4 3 2 3 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ap = 1×48 logical array Columns 1 through 44 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 45 through 48 0 0 0 0 apnum = Columns 1 through 29 1 1 1 2 3 4 3 2 3 4 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ap = 1×48 logical array Columns 1 through 44 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 45 through 48 0 0 0 0 apnum = Columns 1 through 29 1 1 1 2 3 4 3 2 3 4 3 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ap = 1×48 logical array Columns 1 through 44 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 45 through 48 0 0 0 0 apnum = Columns 1 through 29 1 1 1 2 3 4 3 2 3 4 3 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ap = 1×48 logical array Columns 1 through 44 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 Columns 45 through 48 0 0 0 0 apnum = Columns 1 through 29 1 1 1 2 3 4 3 2 3 4 3 1 1 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ap = 1×48 logical array Columns 1 through 44 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 Columns 45 through 48 0 0 0 0 apnum = Columns 1 through 29 1 1 1 2 3 4 3 2 3 4 3 1 1 3 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ap = 1×48 logical array Columns 1 through 44 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 45 through 48 0 0 0 0 apnum = Columns 1 through 29 1 1 1 2 3 4 3 2 3 4 3 1 1 3 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

5   Pass
s = 'In short, in matters vegetable, animal, and mineral, I am the very model of a modern Major-General.'; n = 2; hifreq_correct = 'er'; assert(isequal(nGramFrequency(s,n),hifreq_correct))

ap = 1×98 logical array Columns 1 through 44 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 45 through 88 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 89 through 98 0 0 0 0 0 0 0 0 0 0 apnum = Columns 1 through 29 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 58 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 59 through 87 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 88 through 98 0 0 0 0 0 0 0 0 0 0 0 ap = 1×98 logical array Columns 1 through 44 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 45 through 88 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 Columns 89 through 98 0 0 0 0 0 0 0 0 0 0 apnum = Columns 1 through 29 1 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 58 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 59 through 87 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 88 through 98 0 0 0 0 0 0 0 0 0 0 0 ap = 1×98 logical array Columns 1 through 44 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 45 through 88 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 89 through 98 0 0 0 0 0 0 0 0 0 0 apnum = Columns 1 through 29 1 3 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 58 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 59 through 87 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 88 through 98 0 0 0 0 0 0 0 0 0 0 0 ap = 1×98 logical array Columns 1 through 44 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 45 through 88 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 89 through 98 0 0 0 0 0 0 0 0 0 0 apnum = Columns 1 through 29 1 3 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 58 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 59 through 87 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 88 through 98 0 0 0 0 0 0 0 0 0 0 0 ap = 1×98 logical array Columns 1 through 44 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 45 through 88 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 89 through 98 0 0 0 0 0 0 0 0 0 0 apnum = Columns 1 through 29 1 3 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 58 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 59 through 87 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 88 through 98 0 0 0 0 0 0 0 0 0 0 0 ap = 1×98 logical array Columns 1 through 44 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 45 through 88 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 89 through 98 1 0 0 0 0 0 0 0 0 0 apnum = Columns 1 through 29 1 3 1 1 1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 58 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 59 through 87 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 88 through 98 0 0 0 0 0 0 0 0 0 0 0 ap = 1×98 logical array Columns 1 through 44 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 45 through 88 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 89 through 98 0 0 0 0 0 0 0 0 0 0 apnum = Columns 1 through 29 1 3 1 1 1 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 58 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 59 through 87 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 88 through 98 0 0 0 0 0 0 0 0 0 0 0 ap = 1×98 logical array Columns 1 through 44 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 45 through 88 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 89 through 98 0 0 0 0 0 0 0 0 0 0 apnum = Columns 1 through 29 1 3 1 1 1 2 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 58 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 59 through 87 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 88 through 98 0 0 0 0 0 0 0 0 0 0 0 ap = 1×98 logical array Columns 1 through 44 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 Columns 45 through 88 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...