From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: *** X-Spam-Status: No, score=3.4 required=5.0 tests=BAYES_20,FORGED_GMAIL_RCVD, FREEMAIL_FROM,TO_NO_BRKTS_PCNT autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,279998daf31f95c2,start X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!c19g2000prf.googlegroups.com!not-for-mail From: BULDO Newsgroups: comp.lang.ada Subject: DS-CDMA simulation using Matlab Date: Fri, 28 Mar 2008 20:24:45 -0700 (PDT) Organization: http://groups.google.com Message-ID: <3d9a91d9-6971-476d-a636-d226e7f7c9b0@c19g2000prf.googlegroups.com> NNTP-Posting-Host: 58.25.88.212 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1206761086 10780 127.0.0.1 (29 Mar 2008 03:24:46 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 29 Mar 2008 03:24:46 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: c19g2000prf.googlegroups.com; posting-host=58.25.88.212; posting-account=QmmXlwoAAACjSRupjwf96z568qjqDqTa User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; (R1 1.5); InfoPath.1; .NET CLR 2.0.50727),gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:20627 Date: 2008-03-28T20:24:45-07:00 List-Id: Hi all When i ran ds-cdma code below on matlab, i received this message:??? Undefined function or method 'hrollfcoef' for input arguments of type 'double'. Error in ==> dscdmareal at 20 [xh] = hrollfcoef(irfn,IPOINT,sr,alfs,1); % T FILTER FUNCTION %%%%%% DS-CDMA clear all close all %**************************** Preparation part ***************************** sr = 256000.0; % symbol rate ml = 2; % number of modulation levels br = sr * ml; % bit rate nd = 100; % number of symbol ebn0 = 3; % Eb/No %************************** Filter initialization ************************** irfn = 21; % number of filter taps IPOINT = 8; % number of oversample alfs = 0.5; % roll off factor [xh] = hrollfcoef(irfn,IPOINT,sr,alfs,1); % T FILTER FUNCTION [xh2] = hrollfcoef(irfn,IPOINT,sr,alfs,0); % R FILTER FUNCTION %********************** Spreading code initialization ********************** user = 1; % number of users seq = 1; % 1:M-sequence 2:Gold 3:Orthogonal Gold stage = 3; % number of stages ptap1 = [1 3]; % position of taps for 1st ptap2 = [2 3]; % position of taps for 2nd regi1 = [1 1 1]; % initial value of register for 1st regi2 = [1 1 1]; % initial value of register for 2nd %******************** Generation of the spreading code ********************* switch seq case 1 % M-sequence code = mseq(stage,ptap1,regi1,user); case 2 % Gold sequence m1 = mseq(stage,ptap1,regi1); m2 = mseq(stage,ptap2,regi2); code = goldseq(m1,m2,user); case 3 % Orthogonal Gold sequence m1 = mseq(stage,ptap1,regi1); m2 = mseq(stage,ptap2,regi2); code = [goldseq(m1,m2,user),zeros(user,1)]; end code = code * 2 - 1; clen = length(code); %************************** Fading initialization ************************** rfade = 0; % Rayleigh fading 0:nothing 1:consider itau = [0,8]; % delay time dlvl1 = [0.0,40.0]; % attenuation level n0 = [6,7]; % number of waves to generate fading th1 = [0.0,0.0]; % initial Phase of delayed wave itnd1 = [3001,4004]; % set fading counter now1 = 2; % number of directwave + delayed wave tstp = 1 / sr / IPOINT / clen; % time resolution fd = 160; % doppler frequency [Hz] flat = 1; % flat Rayleigh environment itndel = nd * IPOINT * clen * 30; % number of fading counter to skip %**************************** START CALCULATION **************************** nloop = 10; % simulation number of times for no=1:10, ebn0=no; noe = 0; nod = 0; for ii=1:nloop %****************************** Transmitter ******************************** data = rand(user,nd*ml) > 0.5; [ich, qch] = qpskmod(data,user,nd,ml); % QPSK modulation [ich1,qch1] = spread(ich,qch,code); % spreading [ich2,qch2] = compoversamp2(ich1,qch1,IPOINT); % over sampling [ich3,qch3] = compconv2(ich2,qch2,xh); % filter if user == 1 % transmission ich4 = ich3; qch4 = qch3; else ich4 = sum(ich3); qch4 = sum(qch3); end %***************************** Fading channel ****************************** if rfade == 0 ich5 = ich4; qch5 = qch4; else [ich5,qch5] = sefade(ich4,qch4,itau,dlvl1,th1,n0,itnd1, ... % fading channel now1,length(ich4),tstp,fd,flat); itnd1 = itnd1 + itndel; end %******************************** Receiver ********************************* spow = sum(rot90(ich3.^2 + qch3.^2)) / nd; % attenuation Calculation attn = sqrt(0.5 * spow * sr / br * 10^(-ebn0/10)); [ich6,qch6] = comb2(ich5,qch5,attn); % Add White Gaussian Noise (AWGN) [ich7,qch7] = compconv2(ich6,qch6,xh2); % filter sampl = irfn * IPOINT + 1; ich8 = ich7(:,sampl:IPOINT:IPOINT*nd*clen+sampl-1); qch8 = qch7(:,sampl:IPOINT:IPOINT*nd*clen+sampl-1); [ich9 qch9] = despread(ich8,qch8,code); % despreading demodata = qpskdemod(ich9,qch9,user,nd,ml); % QPSK demodulation %************************** Bit Error Rate (BER) *************************** noe2 = sum(sum(abs(data-demodata))); nod2 = user * nd * ml; noe = noe + noe2; nod = nod + nod2; fprintf('%d\t%e\n',ii,noe2/nod2); end %******************************** Data file ******************************** ber = noe / nod; beri(no)=ber; fprintf('%d\t%d\t%d\t%e\n',ebn0,noe,nod,noe/nod); % fprintf: built in function fid = fopen('BER.dat','a'); fprintf(fid,'%d\t%e\t%f\t%f\t\n',ebn0,noe/nod,noe,nod); % fprintf: built in function fclose(fid); end %******************************** end of file ******************************** %data figure(1),plot(data); xlabel('Time');ylabel('Amplitude');title('data'); %CDMA QPSK modulation ich %figure(2),plot(ich),grid; %xlabel('Time');ylabel('Amplitude');title('QPSK Ich'); %CDMA QPSK modulation qch %figure(3),plot(qch),grid; %xlabel('Time');ylabel('Amplitude');title('QPSK qch'); %spreading %figure(4),plot(ich1),grid; %xlabel('Time');ylabel('Amplitude');title('spreaded Ich'); %figure(5),plot(qch1),grid; %xlabel('Time');ylabel('Amplitude');title('spreaded qch'); %oversampling %figure(6),plot(ich2),grid; %xlabel('Time');ylabel('Amplitude');title('oversampled Ich'); %figure(7),plot(qch2),grid; %xlabel('Time');ylabel('Amplitude');title('oversampled qch'); %filter %figure(8),plot(ich3),grid; %xlabel('Time');ylabel('Amplitude');title('filtered Ich'); %figure(9),plot(qch3),grid; %xlabel('Time');ylabel('Amplitude');title('filtered qch'); %transmission figure(2),plot(ich4),grid; xlabel('Time');ylabel('Amplitude');title('transmission Ich'); figure(3),plot(qch4),grid; xlabel('Time');ylabel('Amplitude');title('transmission qch'); %received signal figure(4),plot(ich7),grid; xlabel('Time');ylabel('Amplitude');title('received Ich'); figure(5),plot(qch7),grid; xlabel('Time');ylabel('Amplitude');title('received qch'); %despread figure(6),plot(ich9),grid; xlabel('Time');ylabel('Amplitude');title('despread Ich'); figure(7),plot(qch9),grid; xlabel('Time');ylabel('Amplitude');title('despread qch'); figure(8),plot(demodata),grid; xlabel('Time');ylabel('Amplitude');title('demodata'); figure(9); semilogy(beri,'*'); hold on for i=1:10, tmp=10^(i/10); tmp=sqrt(tmp); ber(i)=0.5*erfc(tmp); end semilogy(ber),grid; xlabel('Eb/No[dB]');ylabel('BER');title('Performance CDMA'); Can anyone tells how to solve the problem? Thanks,best regards.