error: missing matlab operator.
It's just a simple tutorial from mathworks.com's own communication toolbox tutorial:
%%Setup
%Define parameters
M=16; %Size of constellation. Since 16QAM
k=log2(M); %Number of bits per symbol, k=4 bits
n=3e4; %Number of bits to process, 30000
nsamp=1; %Oversampling rate. Oversampling is the process of sampling a signal with sampling frequency higher than nyquist frequency
%%Signal source
%Create a binary data stream as a column vector
x=randint(n,1); %Random binary data stream, n x 1 matrix (30000 x 1)
%Plot first 40 bits in a stem plot .A stem plot displays data as lines
%(stems) terminated with a marker symbol at each data value.
stem(x(1:40),'filled');
title('Random Bits');
xlabel('Bit index');
ylabel('Binary value');
%--------------------------------------------------------------------------
%%Bit-to-symbol mapping
%Convert bits in x into k-bit symbols
xsym=bi2de(reshape(x,k,length(x)/k).','left-msb');
%%Stem plot of symbols
%Plot first 10 symbols in a stem plot
figure; %Create new figure window
stem(xsym(1:10));
title('Random Symbols');
xlabel('Symbol index');
ylabel('Integer value');
%--------------------------------------------------------------------------
%%Modulation
%Modulate using 16-QAM
y=qammod(xsym,M); %M already defined above as 16
%Transmitted signal
ytx=y;
%%Channel
%Send signal over an AWGN channel
EbNo=10; %in dB
snr=EbNo+10*log10(k)- 10*log10(nsamp);
ynoisy=awgn(ytx,snr,'measured');
%%Recieved signal
yrx=ynoisy;
%%Scatter plot
%Create the scatter plot of noisy signal and transmitted signal on the same
%axes.
h=scatterplot(yrx(1:nsamp*5e3),nsamp,0,'g.');
hold on;
scatterplot(ytx(1:5e3),1,0,'k*',h);
title('Recieved signal');
legend('Recieved signal','Signal constellation');
axis([-5 5 -5 5]); %Set axis ranges
hold off;
%%Demodulation
%Demodulate signal using 16QAM
zsym=qamdemod(yrx,M);
%%Symbol-to-bit mapping
%Undo the bit-to-symbol mapping performed earlier
z=de2bi(zsym,'left-msb'); %Convert integer to bits
%Convert z from a matrix to a vector
z=reshape(z.',prod(size(z)),1); %.' = array transpose
%%BER computation
%Compare x and z to obtain the number of errors and the bit error rate
[number_of_errors,bit_error_rate]=biterr(x,z)
I don't think there is anything wrong with the code since when i paste the code into the command window, it runs. But strange is that i can't run from the M-file editor or by typing run abc.m or abc.m or abc etc....this shouldn't be right?
My friend running the same code doesn't seem to have any problem running from the editor or just by typing the .m filename.
It's nothing serious actually, since i still can run codes...its just...well...strange....