MATLAB: Index Exceeds the number of array elements (993268)

arrayexceedMATLAB

I am trying to run my following code for a large data packet size, but when I do, I get the following error: "Index Exceeds the number of array elements (993268)" and "Index exceeds the number of array elements (0)" The error is in line 10 and 18. I am not sure what to do to resolve this issue, any help would be appreciated.
Thank you
clear all
clc
filetext = fileread('1066desk.txt');
a=length(filetext);
b=round(a/100);
iwant = cell(1,b) ;
iwant{1}=filetext(1:100);
for i = 2:b
iwant{i} = filetext((i-1)*100+1:i*100) ;
end
%% 100 to 8 division
c = cell(13,b) ;
for i=1:b
for j=1:13
if j==1
c{j,i}=iwant{i}(j:8*j);
f(j,i) = hex2dec(c(j,i)) ;
else if j==2
c{j,i}=iwant{i}(8*(j-1)+1:8*j);
f(j,i) = hex2dec(c(j,i)) ;
else if j==13
c{j,i}=iwant{i}(j*8-7:8*j-4);
f(j,i) = hex2dec(c(j,i)) ;
else if j==12
c{j,i}=iwant{i}(8*(j-1)+1:8*j);
f(j,i) = hex2dec(c(j,i)) ;
else
c{j,i}=iwant{i}(8*(j-1)+1:8*j);
f(j,i) = typecast(uint32(hex2dec(c(j,i))),'single');
end
end
end
end
end
end
g=f.*[1;1/(16*10^6);1;1;1;1;1;1;.3;.3;.3;1/4096;1];
plot(f(2,:)*1/(16*10^6),f(5,:))
title('Row 2 verses Row 5')
xlabel('Row2');
ylabel('Row5')

Best Answer

If you have an array with 10 elements but you are trying to access the 11th element, you got this error. Just step through your code and verify the numbers.
a=ones(10,1)
a(11)