Not enough input arguments for awgn function
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
qianhui zhou
am 15 Apr. 2018
Kommentiert: qianhui zhou
am 15 Apr. 2018
Hi,I'm very new to the MATLAB and I just got a question, the code is for generate a random signal and then add a white noise to it:
%define variables
N = 10;
k = 1;
fc = 2000;
%create a random binary stream of N bits
data = randi([0 1],N,1);
%sample at 8 samples/bit (8*N samples)
for i = 1:N
for j = 1:8
y(k) = data(i);
k = k+1;
end
end
%modulate the sampled signal
t = linspace(0,0.8*N,8*N);
z = y.*cos(2*pi*fc*t);
g = awgn(z,snr,'measured');
after that, it tells me:
Error using snr (line 84)
Not enough input arguments.
Does anyone knows How to solve that?
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 15 Apr. 2018
awgn() expects you to pass a numeric value for the signal to noise ratio. Instead in that position you mention snr . snr happens to be the name of a function, so MATLAB tries to invoke the function at that point. But the function needs arguments...
You should be assigning a value to snr before you call awgn.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Propagation and Channel Models finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!