Reply by John March 22, 20082008-03-22
On Mar 21, 10:11 pm, BULDO <mikailid...@gmail.com> wrote:
> I am simulating MC-CDMA using Matlab. Here is the message Maltab > returned when I ran the simulation: > > Undefined function or method 'snr' for input arguments of type 'char'. > Error in ==> MCCDMA at 10 > snr _in_ dB = 0:1:15; >
Have you tried trimming the spaces out of that expression? John
Reply by BULDO March 21, 20082008-03-21
I am simulating MC-CDMA using Matlab. Here is the message Maltab
returned when I ran the simulation:

Undefined function or method 'snr' for input arguments of type 'char'.
Error in ==> MCCDMA at 10
snr _in_ dB = 0:1:15;

I am using Matlab 2007b and the Matlab code is:


% MCCDMA %
% for simulation %
%%%%%%%%%%%%%%%%%%%%
%%% Transmitter Model %%%
clear all;
clc;close all;
tic;                % start a stopwatch timer
xaxis=[];
yaxis=[];
snr _in_ dB = 0:1:15;
R= 100;
for n=1:lentgh(snr_in_dB)
    no_of_errors=0;
    for m=1:R
        N=8;            %no of subchannels
        ifft_size=N;    %ifft size
        fft_size=N;     %fft size
        M=100000;      % nos of data in each subchannel
        total_no_of_data= N*M;
    rand_data_seed=11;
    % Generation of N parallel dada sequence
    rand('seed',rand_data_seed);
    user_data_matrix=rand(N,M);
    user_data_matrix=(user_data_matrix>0.5)*2-1;
    % Calling of function for code matrix
    code_mat=code_matrix(N,'hada_11');
    trans_code_mat_out=(conj(code_mat))*user_data_matrix;
    % IFFT of the code matrix out
    trans_ifft_out=iff(trans_code_mat_out,ifft_size);
    % Normalization of IFFT
    trans_ifft_out_nor=trans_ifft_out* sqrt(N);
    % Parallel to serial of transmit signal
    trans_sig_serial=reshape(trans_ifft_out_nor,1,N*M);
    recv_sig_serial=trans_sig_serial;
    %%% Receiver Model %%%
    % Serial to parallel for received signal
    recv_signal_parallel=reshape(recv_signal_serial,N*M);
    % Taking FFT of the received signal(parallel)
    recv_fft_out=fft(recv_signal_parallel,fft_size);
    % Normalization of the FFT
    recv_fft_out_nor=recv_fft_out/sqrt(N);
    % Calling function for weight matrix
    [weight_mat,diag_h]=weight_mat(N,'awgn');
    % Multiplication of Rayleigh Noise with FFT out
    recv_fft_out_rayleigh=diag_h*recv_fft_out_nor;
    % Addition of AWGN
 
recv_fft_awgn_out=awgn(recv_fft_out_rayleig,SNR_in_dB(n),'measured');
    recv_fft_out_noise=recv_fft_awgn_out-recv_fft_out_rayleigh;
    recv_fft_awgn_out=recv_fft_out_rayleigh+(recv_fft_out_noise/
sqrt(2));
    % Multiplication by weight matrix
    recv_wmat_out=weight_mat*recv_fft_awgn_out;
    % Taking inverse of code matrix
    inv_code_mat=inv(code_mat);
    % Multiplication by Inverse Code Matrix
    out_data_parallel=inv_code_mat*(recv_wmat_out);
    % Taking real part of the out_data_ parallel matrix
    real_out_data_parallel=real(out_data_parallel);
    % Converting the real_out_parallel matrix to '1' and '-1'
    out_user_data_matrix=(real_out_data_parallel>0)*2-1;
    % Parallel to serial conversion of out data
    out_data_serial=reshape(out_user_data_matrix,1,N*M);
    %%% calculation of bit error rate %%%
    % regeneration of transmitted user data matrix
    rand('seed',rand_data_seed);
    trans_user_data_matrix=rand(N,M);
    trans_user_data_matrix=(trans_user_data_matrix>0.5)*2-1;
    % Calculation of bit error rate
 
[no_of_errors,symbol_error_rate]=symerr(trans_user_data_matrix,out_user_data_matrix);
    no_of_errors=no_of_errors+no_of_errors;
    end;
    sym_err_rate=no_of_errors/total_no_of_data;
    ber_simulated=sym_err_rate/1.0;
    ber_simulated;
    yaxis=[yaxis,ber_simulated];
end;
xaxis=[xaxis,SNR_in_dB];
% Save BER for different SNR
save ybhawgns.mat yaxis;
% Plotting command follows
seminolog(xaxis,yyaxis,'g-');
ylabel('.............SNR(dB).............');
ylabel('.............AverageBER..........');
axis([0 17 0.000001 0.1]);
toc;              % read the stop watchtimer,print time in second
%%%  End of program      %%%



   Thanks for you help,take care!