Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: MC-CDMA simulation using Matlab

76 views
Skip to first unread message
Message has been deleted

Amir

unread,
Mar 21, 2008, 10:45:04 PM3/21/08
to
BULDO <mikai...@gmail.com> wrote in message <5452bf3f-
bdde-41b0-97c6-
25b5ee...@i29g2000prf.googlegroups.com>...
> 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!

You have a typo in that line. You have a space between snr
and _in_ dB:

snr _in_ dB = 0:1:15; wrong, space after snr
snr_in_ dB = 0:1:15; %Correct, no space after snr

BULDO

unread,
Mar 21, 2008, 11:18:10 PM3/21/08
to
Thanks for your help, but after i corrected the previous mistake, i
got a new error:??? Undefined function or method 'lentgh' for input
arguments of type 'double'.

Error in ==> MCCDMA at 12
for n=1:lentgh(snr_in_dB)
Take care!
On Mar 22, 10:45 am, "Amir " <amir_se...@yahoo.com> wrote:
> BULDO <mikailid...@gmail.com> wrote in message <5452bf3f-
>
> bdde-41b0-97c6-
> 25b5ee902...@i29g2000prf.googlegroups.com>...

> snr_in_ dB = 0:1:15; %Correct, no space after snr- Hide quoted text -
>
> - Show quoted text -- Hide quoted text -
>
> - Show quoted text -- Hide quoted text -
>
> - Show quoted text -

Walter Roberson

unread,
Mar 22, 2008, 1:25:01 AM3/22/08
to
In article <0612995c-3e43-424b...@s12g2000prg.googlegroups.com>,

BULDO <mikai...@gmail.com> wrote:
>Thanks for your help, but after i corrected the previous mistake, i
>got a new error:??? Undefined function or method 'lentgh' for input
>arguments of type 'double'.

Try 'length' instead of 'lentgh'.
--
"Product of a myriad various minds and contending tongues, compact of
obscure and minute association, a language has its own abundant and
often recondite laws, in the habitual and summary recognition of
which scholarship consists." -- Walter Pater

BULDO

unread,
Mar 22, 2008, 4:54:30 AM3/22/08
to
On Mar 22, 1:25 pm, rober...@ibd.nrc-cnrc.gc.ca (Walter Roberson)
wrote:
> In article <0612995c-3e43-424b-94c7-cc9d566af...@s12g2000prg.googlegroups.com>,

>
> BULDO  <mikailid...@gmail.com> wrote:
> >Thanks for your help, but after i corrected the previous mistake, i
> >got a new error:??? Undefined function or method 'lentgh' for input
> >arguments of type 'double'.
>
> Try 'length' instead of 'lentgh'.
> --
>   "Product of a myriad various minds and contending tongues, compact of
>   obscure and minute association, a language has its own abundant and
>   often recondite laws, in the habitual and summary recognition of
>   which scholarship consists."                -- Walter Pater

Thanks a lot Walter Pater,
But this doesn't solve the problem. Take care!

Mikail

unread,
Mar 22, 2008, 5:51:02 AM3/22/08
to
Hi,
Thanks for your help,but this didn't solve the problem.
Regars
robe...@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in
message <fs257d$7kc$1...@canopus.cc.umanitoba.ca>...
> In article <0612995c-3e43-424b-94c7-
cc9d56...@s12g2000prg.googlegroups.com>,

Logan Wolverine

unread,
Mar 30, 2008, 3:29:04 AM3/30/08
to
BULDO <mikai...@gmail.com> wrote in message
<5452bf3f-bdde-41b0...@i29g2000prf.googlegroups.com>...

> 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

I hav Got an error of line 26
"Undefined command/function 'code_matrix'.

Error in ==> Mc at 26
code_mat=code_matrix(N,'hada_11');"

Can anyone please help me on that error......


lenin ram

unread,
Oct 31, 2008, 11:28:02 AM10/31/08
to


send me the entire program including function program then only we can able to rectify the complete errors

saumya mohapatra

unread,
Sep 29, 2009, 1:45:19 PM9/29/09
to
"lenin ram" <leni...@rediffmail.com> wrote in message <gef862$lr4$1...@fred.mathworks.com>...
> >if you will send the entire program like send the each function i will help you
i'm also doing research on 4G technology...

Montadar Taher

unread,
Nov 2, 2009, 4:19:03 PM11/2/09
to
hi friends,

i need a very simple matlab program code for cdma as i am new to cdma programming.

please help me

deepak sheoran

unread,
Nov 17, 2009, 4:24:01 AM11/17/09
to
"Montadar Taher" <muntath...@yahoo.com> wrote in message <hcnic7$r1v$1...@fred.mathworks.com>...

> hi friends,
>
> i need a very simple matlab program code for cdma as i am new to cdma programming.
>
> please help me

even i also need the simple cdma code.
can anybody help me with this

venkat venkatesh

unread,
Dec 30, 2009, 2:35:21 AM12/30/09
to
BULDO <mikai...@gmail.com> wrote in message <0612995c-3e43-424b...@s12g2000prg.googlegroups.com>...

> Thanks for your help, but after i corrected the previous mistake, i
> got a new error:??? Undefined function or method 'lentgh' for input
> arguments of type 'double'.
>
> Error in =3D=3D> MCCDMA at 12
> for n=3D1:lentgh(snr_in_dB)
> Take care!

> On Mar 22, 10:45=A0am, "Amir " <amir_se...@yahoo.com> wrote:
> > BULDO <mikailid...@gmail.com> wrote in message <5452bf3f-
> >
> > bdde-41b0-97c6-
> > 25b5ee902...@i29g2000prf.googlegroups.com>...
> >
> >
> >
> > > 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 =3D=3D> MCCDMA at 10
> > > snr _in_ dB =3D 0:1:15;

> >
> > > I am using Matlab 2007b and the Matlab code is:
> >
> > > % MCCDMA %
> > > % for simulation %
> > > %%%%%%%%%%%%%%%%%%%%
> > > %%% Transmitter Model %%%
> > > clear all;
> > > clc;close all;
> > > tic; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0% start a stopwatch timer
> > > xaxis=3D[];
> > > yaxis=3D[];
> > > snr _in_ dB =3D 0:1:15;
> > > R=3D 100;
> > > for n=3D1:lentgh(snr_in_dB)
> > > =A0 =A0 no_of_errors=3D0;
> > > =A0 =A0 for m=3D1:R
> > > =A0 =A0 =A0 =A0 N=3D8; =A0 =A0 =A0 =A0 =A0 =A0%no of subchannels
> > > =A0 =A0 =A0 =A0 ifft_size=3DN; =A0 =A0%ifft size
> > > =A0 =A0 =A0 =A0 fft_size=3DN; =A0 =A0 %fft size
> > > =A0 =A0 =A0 =A0 M=3D100000; =A0 =A0 =A0% nos of data in each subchannel
> > > =A0 =A0 =A0 =A0 total_no_of_data=3D N*M;
> > > =A0 =A0 rand_data_seed=3D11;
> > > =A0 =A0 % Generation of N parallel dada sequence
> > > =A0 =A0 rand('seed',rand_data_seed);
> > > =A0 =A0 user_data_matrix=3Drand(N,M);
> > > =A0 =A0 user_data_matrix=3D(user_data_matrix>0.5)*2-1;
> > > =A0 =A0 % Calling of function for code matrix
> > > =A0 =A0 code_mat=3Dcode_matrix(N,'hada_11');
> > > =A0 =A0 trans_code_mat_out=3D(conj(code_mat))*user_data_matrix;
> > > =A0 =A0 % IFFT of the code matrix out
> > > =A0 =A0 trans_ifft_out=3Diff(trans_code_mat_out,ifft_size);
> > > =A0 =A0 % Normalization of IFFT
> > > =A0 =A0 trans_ifft_out_nor=3Dtrans_ifft_out* sqrt(N);
> > > =A0 =A0 % Parallel to serial of transmit signal
> > > =A0 =A0 trans_sig_serial=3Dreshape(trans_ifft_out_nor,1,N*M);
> > > =A0 =A0 recv_sig_serial=3Dtrans_sig_serial;
> > > =A0 =A0 %%% Receiver Model %%%
> > > =A0 =A0 % Serial to parallel for received signal
> > > =A0 =A0 recv_signal_parallel=3Dreshape(recv_signal_serial,N*M);
> > > =A0 =A0 % Taking FFT of the received signal(parallel)
> > > =A0 =A0 recv_fft_out=3Dfft(recv_signal_parallel,fft_size);
> > > =A0 =A0 % Normalization of the FFT
> > > =A0 =A0 recv_fft_out_nor=3Drecv_fft_out/sqrt(N);
> > > =A0 =A0 % Calling function for weight matrix
> > > =A0 =A0 [weight_mat,diag_h]=3Dweight_mat(N,'awgn');
> > > =A0 =A0 % Multiplication of Rayleigh Noise with FFT out
> > > =A0 =A0 recv_fft_out_rayleigh=3Ddiag_h*recv_fft_out_nor;
> > > =A0 =A0 % Addition of AWGN
> >
> > > recv_fft_awgn_out=3Dawgn(recv_fft_out_rayleig,SNR_in_dB
> > (n),'measured');
> > > =A0 =A0 recv_fft_out_noise=3Drecv_fft_awgn_out-
> >
> > recv_fft_out_rayleigh;> =A0 =A0 recv_fft_awgn_out=3Drecv_fft_out_rayleigh+=
>
> >
> > (recv_fft_out_noise/
> >
> >
> >
> > > sqrt(2));
> > > =A0 =A0 % Multiplication by weight matrix
> > > =A0 =A0 recv_wmat_out=3Dweight_mat*recv_fft_awgn_out;
> > > =A0 =A0 % Taking inverse of code matrix
> > > =A0 =A0 inv_code_mat=3Dinv(code_mat);
> > > =A0 =A0 % Multiplication by Inverse Code Matrix
> > > =A0 =A0 out_data_parallel=3Dinv_code_mat*(recv_wmat_out);
> > > =A0 =A0 % Taking real part of the out_data_ parallel matrix
> > > =A0 =A0 real_out_data_parallel=3Dreal(out_data_parallel);
> > > =A0 =A0 % Converting the real_out_parallel matrix to '1'
> > and '-1'
> > > =A0 =A0 out_user_data_matrix=3D(real_out_data_parallel>0)*2-1;
> > > =A0 =A0 % Parallel to serial conversion of out data
> > > =A0 =A0 out_data_serial=3Dreshape(out_user_data_matrix,1,N*M);
> > > =A0 =A0 %%% calculation of bit error rate %%%
> > > =A0 =A0 % regeneration of transmitted user data matrix
> > > =A0 =A0 rand('seed',rand_data_seed);
> > > =A0 =A0 trans_user_data_matrix=3Drand(N,M);
> > > =A0 =A0 trans_user_data_matrix=3D(trans_user_data_matrix>0.5)
> > *2-1;
> > > =A0 =A0 % Calculation of bit error rate
> >
> > > [no_of_errors,symbol_error_rate]=3Dsymerr
> >
> > (trans_user_data_matrix,out_user_data_matrix);
> >
> >
> >
> >
> >
> > > =A0 =A0 no_of_errors=3Dno_of_errors+no_of_errors;
> > > =A0 =A0 end;
> > > =A0 =A0 sym_err_rate=3Dno_of_errors/total_no_of_data;
> > > =A0 =A0 ber_simulated=3Dsym_err_rate/1.0;
> > > =A0 =A0 ber_simulated;
> > > =A0 =A0 yaxis=3D[yaxis,ber_simulated];
> > > end;
> > > xaxis=3D[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; =A0 =A0 =A0 =A0 =A0 =A0 =A0% read the stop watchtimer,print time
> > in second
> > > %%% =A0End of program =A0 =A0 =A0%%%
> >
> > > =A0 =A0Thanks for you help,take care!

> >
> > You have a typo in that line. You have a space between snr
> > and _in_ dB:
> >
> > snr _in_ dB =3D 0:1:15; wrong, space after snr
> > snr_in_ dB =3D 0:1:15; %Correct, no space after snr- Hide quoted text -

Jorian

unread,
Mar 7, 2010, 5:48:05 AM3/7/10
to
"Amir " <amir_...@yahoo.com> wrote in message <fs1rrg$mb0$1...@fred.mathworks.com>...

> BULDO <mikai...@gmail.com> wrote in message <5452bf3f-
> bdde-41b0-97c6-
> 25b5ee...@i29g2000prf.googlegroups.com>...
> > 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;
> > http://www.musicpa.com

Thanks

mohamed abourafia

unread,
Apr 10, 2011, 4:50:04 PM4/10/11
to
hi,

i am trying to run the code you provided for MC-CDMA. but it won't work. gives an error massege for syntax belows. is there a missing file should work with this code?
( : ??? Undefined function or method 'code_matrix' for input arguments
of type 'double'.

Error in ==> Untitled2 at 22
code_mat=code_matrix(N,'hada_11'); )

% Calling of function for code matrix
code_mat=code_matrix(N,'hada_11');

% Calling function for weight matrix
[weight_mat,diag_h]=weight_mat(N,'awgn');

thanks for your help,

0 new messages