#### moneer

##### Newbie level 5

**CDMA-OFDM code**

hi

iam doing ofdm-cdma matlab code.

the problem when i simulate for 2 users i get the recieved data wrong or when try to simulate using raylighy channels. i cant decide what is wrong with the code if some one can help me

thanks

%% code

clc

clear all

close all

sf=64;

user1=randint(16, 1, 2)

user2=randint(16, 1, 2);

% Create BPSK mod-demod objects

P = 2; % modulation order

bpskmod = modem.pskmod('M', P, 'SymbolOrder', 'Gray');

bpskdemod = modem.pskdemod(bpskmod);

user1tx = modulate(bpskmod, user1); % BPSK modulation

user2tx = modulate(bpskmod, user2);

user1_ofdm = ifft(user1tx,16);

user2_ofdm = ifft(user2tx,16);

pn1 = [1; -1; 1; -1; 1; 1; 1; -1];

pn2 = [-1; 1; -1; 1; -1; -1; -1; 1];

user1spread = rectpulse(user1_ofdm, sf);

user2spread = rectpulse(user2_ofdm, sf);

user1pn = rectpulse(pn1, 2*sf);

user2pn = rectpulse(pn2, 2*sf);

tx1 = user1spread .* user1pn;

tx2 = user2spread .* user2pn;

rec = (tx1+tx2);

user1rec = rec .* user1pn;

user1down = intdump (user1rec, sf);

user1_fft = fft (user1down, 16);

user1rx = demodulate(bpskdemod, user1down)