If you got this code from someone else and it should be working (because it used to work with the exact same parameters), my guess is that the person wrote it for/on a recent version of MATLAB that supports implicit expansion, and you are trying to run it on an older version that requires explicit calls to BSXFUN for performing operations with implicit expansion (..).
On recent versions you can do this:
>> x = 1 : 5
x =
1 2 3 4 5
>> Y = repmat( 21:25, 4, 1 )
Y =
21 22 23 24 25
21 22 23 24 25
21 22 23 24 25
21 22 23 24 25
>> x .* Y
ans =
21 44 69 96 125
21 44 69 96 125
21 44 69 96 125
21 44 69 96 125
where you can observe an automatic expansion of x along dim 1, otherwise we could not perform this element-wise multiplication. On former version of MATLAB, we had to proceed as follows:
>> bsxfun( @times, x, Y )
ans =
21 44 69 96 125
21 44 69 96 125
21 44 69 96 125
21 44 69 96 125
If this is what is happening (based on your screenshots it could be), then you have to update the code and implement relevant calls to BSXFUN. For the line where you have the error, this should be:
BPSK_RX_signal = bsxfun( @times, channel, BPSK_RX_signal ) + noise;
where both channel and noise are 8x1000 and BPSK_RX_signal is 1x1000.
If the code has never worked before, the error may be elsewhere.
EDIT: I don't understand how channel and noise can be 8x1000 with this code by the way, so the error should be elsewhere.
Best Answer