Splitting array into two
365 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 External Language Interfaces 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!