Attempted to access Y(2,3009); index out of bounds because size(Y)=[64,576].
Show older comments
Y = sort(cell2mat(transpose(C)));
a=zeros(64,1);
col1=1;
col2=64;
for z=1:47
for i=1:64
for j=col1:col2
k=1;
if Y(i,j)==Y(i,j+12)
v=Y(i,j);
a=v;
a=a+1;
else
end
if col2==3072
break
else
col1=col1+64;
col2=col2+64;
end
end
end
end
5 Comments
Guillaume
on 21 May 2015
Instead of putting blank lines between each line of code (which must have been a pain!), just paste your code and click on the {} Code button.
B.k Sumedha
on 21 May 2015
@B.k Sumedha: instead of giving us some broken code to interpret, it would be much better if you describe what you are trying to achieve, and we will figure out a nice tidy way of solving it.
It is not clear from that code what you are trying to achieve, but given the nested loops and ifs and breaks it seems quite likely that there would be much simpler and faster way to achieve it.
And please provide some test data too!
B.k Sumedha
on 21 May 2015
Walter Roberson
on 21 May 2015
The file did not get attached, and you also did not describe what you are trying to do.
Answers (1)
Walter Roberson
on 21 May 2015
0 votes
There is no way in your code for col1 or col2 to ever decrease once they have increased.
You start col1 at 1, and you start col2 at 64, and you increase both col1 and col2 by 64 each until col2 becomes 3072 (48*64). As you increase both at the same time, col1 is going to be 63 less than col2, so when col2 is 3072, col1 will be 3009. And then you loop back over j=col1:col2 so j is going to become 3009, which is past the end of the matrix.
I recognize the code as having to do with steganography.
Categories
Find more on Performance and Memory in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!