Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

how to solve index exceeds dimensions

조회 수: 1 (최근 30일)
Ayesha Punjabi
Ayesha Punjabi 2019년 6월 6일
마감: MATLAB Answer Bot 2021년 8월 20일
a is 1*80 bit matrix
b is 1*16 matrix. This remains same. All the 16 binary bits in b remains same
code is 1*16 matrix. Code variable changes and selects diffierent 16 binary bits. Each time it has random, different selection of binary bits.
bits = 5;
gain = 16;
for p = 1:bits
for m = 1:gain
position=m+(p-1)*gain;
a(position) = xor(b(position),code(m));
end
end
I am getting index exceeds dimensions error in a(position) = xor(b(position),code(m)); the idea is to put 1st xor(b and code) in first 16 bits of a, in 2nd run next xor(b and code) in 17-31 columns of a and so on.
Kindly help in solving the error.
  댓글 수: 1
KSSV
KSSV 2019년 6월 7일
In the loop position = 17. And you have b, code as 1x16...so obviously you will get this error.

답변 (1개)

Debasish Samal
Debasish Samal 2019년 6월 7일
In the line a(position) = xor(b(position),code(m));
The variable 'position' should not be used for indexing into b as it will exceed the size of b when m>1.
replace 'position' by m. That should solve the issue.
a(position) = xor(b(m),code(m));
Good Luck!

이 질문은 마감되었습니다.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by