how to remove error in this code?

%%K=10%%
a = 1000;
a = rand([-1 1],a,1);
b= (a >= 0);
bm=(a<0);
b1(b)=1;
b1(bm)=-1;
d=b1(:);
h=[1 0.25 -0.5];
c=conv(h,d);
e=c(1:end-2,:);
noise1 =normrnd(0,0.1,[length(e)],1); % noise signal of zero mean and 0.1 variance
f1= e+noise1;
t=f1(1:end-990,:); %take 10 values
ss = 16; % NLMS step size
offset = 50; % NLMS offset
ha = adaptfilt.nlms(3,ss,1,offset);
stem([h', ha.coefficients']);
legend('Actual','Estimated');
xlabel('Coefficient number'); ylabel('Coefficient Value');

1 Comment

Jan
Jan on 9 Apr 2016
Edited: Jan on 9 Apr 2016
I've formatted your code using the "{} code" button. Please care about readable code in the future - thanks!
Whenever you mention an error in the forum, post the complete error message.

Sign in to comment.

Answers (1)

The error message is clear:
a = rand([-1 1],a,1);
Error using rand
Size inputs must be scalar.
Perhaps you meant randi.

Tags

Asked:

on 9 Apr 2016

Edited:

Jan
on 9 Apr 2016

Community Treasure Hunt

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

Start Hunting!