Splitting array into two

조회 수: 365 (최근 30일)
Przemyslaw
Przemyslaw 2014년 5월 2일
댓글: José-Luis 2014년 5월 2일
Hello everyone, I have a project, to design QAM MOD/DEMOD. My Matlab programming skills are bit rusty, and right now I have stucked on a very simple task. For modulator I have to split my bit-stream into two halves. I thought I managed to obtain a solution, but I still get an error: Subscript indices must either be real positive integers or logicals.
The code is below:
function split_stream(x) %x is bit-stream
lx = (length(x));
half = ceil(lx/2); %for odd number of bit-stream length
s1 = x(1,0:half)
s2 = x(1,half + 1:lx)
end
I would really appreciate if somebody could instruct me, where I am making a mistake.

채택된 답변

José-Luis
José-Luis 2014년 5월 2일
s1 = x(1:half);
s2 = x(half + 1 : end);
Indexing starts at one in Matlab. Please accept an answer if it helped you.
  댓글 수: 2
Przemyslaw
Przemyslaw 2014년 5월 2일
Thank You! Oh My, I was so close, yet still so far from solution :). Everything works like a charm!
José-Luis
José-Luis 2014년 5월 2일
My pleasure.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 External Language Interfaces에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by