Error using .* Matrix dimensions must agree.

1 view (last 30 days)
hi i am new and need help with this, try to follow the steps of the program but it keeps coming this error.
please help!
Error using .* Matrix dimensions must agree.
m=8;
n=2^m-1;
k=233;
t=(n-k)/2;
nw=1;
msgw=gf(randint(nw,k,2^m),m);
c=rsenc(msgw,n,k);
*noise=(1+randint(nw,k,2^m-1)).*randerr(nw,n,t);*
cnoisy=c+noise;
[dc,nerrs,corrcode]=rsdec(cnoisy,n,k);
isequal(dc,msgw)& isequal(corrcode,c);
nerrs;

Answers (1)

Walter Roberson
Walter Roberson on 13 Oct 2015
In randint(nw,k,2^m-1), 2^m-1 is the same as n, so this is the same as randint(nw,k,n) . That will generate a k by n array of random integers in the range 1 to nw.
randerr(nw,n,t) will generate an nw by n array with t non-zero entries per line.
You attempt to use .* to multiply those two arrays. In order to use .* the arrays must be the same size or at least one of the operands must be a scalar.
We are comparing a k by n array in size to an nw by n array. Those are the same size only if k == nw . Which it certainly does not.

Categories

Find more on Sparse Matrices in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!