I am trying to convert the string into binary and sequencing with DNA,but i am getting error as follows :
Attempted to access bases(145); index out of bounds because numel(bases)=4.Error in ==> filename at 21result((k+1)/2) = bases(index);
What is the solution for this? Here is the code:
clc;ui=input('enter the message:','s')decString = unicode2native(ui,'utf-8')hexString = dec2hex(decString)binaryArray= dec2bin(decString,8)bases = 'ATGC';for k = 1 : 2 : length(binaryArray) % Convert these two digits into a number 1 - 4.
index = 2 * binaryArray(k) + binaryArray(k+1) + 1; % Use that index to assign a letter to our result.
result((k+1)/2) = bases(index);end% Display in command window:
result
Thank you
Best Answer