Performance of a Coded Multi-Carrier DS-CDMA System in Multi-Path Fading Channels

INTRODUCTION

Digital Signal Processing (DSP) is concerned with the representation, transformation and manipulation of signals on a computer. Nowadays, DSP has become an important field, and has penetrated a wide range of application systems, such as consumer electronics, digital communications, medical imaging and so on. With the dramatic increase of the processing capability of signal processing microprocessors, it is the expectation that the importance and role of DSP is to accelerate and expand.

DSP stands for Digital Signal Processing - the basis of many areas of technology, from mobile phones to modems and multimedia PCs. A signal in this context can mean a number of different things. The term "digital" comes from "digit", meaning a number so "digital" literally means numerical. Digital Signal Processing is the science of using computers to understand these types of data. A signal is any variable that carries information.

Examples of the types of signals of interest are

  • Speech (telephony, radio, everyday communication)
  • Biomedical signals (EEG brain signals)
  • Sound and music
  • Video and image
  • Radar signals (range and bearing).

Image processing is important in modern data storage and data transmission especially in progressive transmission of images, video coding (teleconferencing), digital libraries, and image database, remote sensing. It has to do with manipulation of images done by algorithm to produce desired images. Digital Signal Processing (DSP) improve the quality of images taken under extremely unfavourable conditions in several ways: brightness and contrast adjustment, edge detection, noise reduction, focus adjustment, motion blur reduction etc .The advantage is that image processing allows much wider range of algorithms to be applied to the input data in order to avoid problems such as the build-up of noise and signal distortion during processing.

ANALOG AND DIGITAL SIGNALS

The signal is initially generated is in the form of an analog electrical voltage or current, produced for example by a microphone or some other type of transducer. The output from the readout system of a CD (compact disc) player, the data is already in digital form. An analog signal must be converted into digital form before DSP techniques can be applied. An analog electrical voltage signal, for example, can be digitized using an electronic circuit called an analog-to-digital converter or ADC. This generates a digital output as a stream of binary numbers whose values represent the electrical voltage input to the device at each sampling instant.

Digital signal processing (DSP)-digital representation of signals and the use of digital processors to analyze, modify, or extract information from signals. Many signals in DSP are derived from analogue signals which have been sampled at regular intervals and converted into digital form. The key advantages of DSP over analogue processing are

  • Guaranteed accuracy (determined by the number of bits used)
  • Perfect reproducibility
  • No drift in performance due to temperature or age
  • Takes advantage of advances in semiconductor technology
  • Greater flexibility (can be reprogrammed without modifying hardware)
  • Superior performance (linear phase response possible, and filtering
  • algorithms can be made adaptive)
  • Sometimes information may already be in digital form.
  • There are however (still) some disadvantages
  • Speed and cost (DSP design and hardware may be expensive, especially with high bandwidth signals)
  • Finite word length problems (limited number of bits may cause degradation).

Application areas of DSP are considerable:

  1. Image processing (pattern recognition, robotic vision, image enhancement, facsimile, satellite weather map, animation)
  2. Instrumentation and control (spectrum analysis, position and rate control, noise reduction, data compression)
  3. Speech and audio (speech recognition, speech synthesis, text to speech, digital audio, equalisation)
  4. Military (secure communication, radar processing, sonar processing, missile guidance)
  5. Telecommunications (echo cancellation, adaptive equalisation, spread spectrum, video conferencing, data communication)
  6. Biomedical (patient monitoring, scanners, EEG brain mappers, ECG analysis, X-ray storage and enhancement).

INTRODUCTION TO CDMA

Code Division Multiple Access (CDMA) is a radically new concept in wireless communications. It has gained widespread international acceptance by cellular radio system operators as an upgrade that will dramatically increase both their system capacity and the service quality. It has likewise been chosen for deployment by the majority of the winners of the United States Personal Communications System spectrum auctions. It may seem, however, mysterious for those who aren't familiar with it.

CDMA is a form of spread-spectrum, a family of digital communication techniques that have been used in military applications for many years. The core principle of spread spectrum is the use of noise-like carrier waves, and, as the name implies, bandwidths much wider than that required for simple point-to-point communication at the same data rate. Originally there were two motivations: either to resist enemy efforts to jam the communications (anti-jam, or AJ), or to hide the fact that communication was even taking place, sometimes called low probability of intercept (LPI). It has a history that goes back to the early days of World War II.

The use of CDMA for civilian mobile radio applications is novel. It was proposed theoretically in the late 1940's, but the practical application in the civilian marketplace did not take place until 40 years later. Commercial applications became possible because of two evolutionary developments. One was the availability of very low cost, high density digital integrated circuits, which reduce the size, weight, and cost of the subscriber stations to an acceptably low level. The other was the realization that optimal multiple access communication requires that all user stations regulate their transmitter powers to the lowest that will achieve adequate signal quality.

CDMA changes the nature of the subscriber station from a predominately analog device to a predominately digital device. Old-fashioned radio receivers separate stations or channels by filtering in the frequency domain. CDMA receivers do not eliminate analog processing entirely, but they separate communication channels by means of a pseudorandom modulation that is applied and removed in the digital domain, not on the basis of frequency. Multiple users occupy the same frequency band. This universal frequency reuse is not fortuitous. On the contrary, it is crucial to the very high spectral efficiency that is the hallmark of CDMA. Other discussions in these pages show why this is true.

CDMA is altering the face of cellular and PCS communication by:

Dramatically improving the telephone traffic caacity

Dramatically improving the voice quality and eliminating the audible effects of multipath fading

Reducing the incidence of dropped calls due to handoff failures

Providing reliable transport mechanism for data communications, such as facsimile and internet traffic

Reducing the number of sites needed to support any given amount of traffic

Simplifying site selection

Reducing deployment and operating costs because fewer cell sites are needed

Reducing average transmitted power

Reducing interference to other electronic devices

Reducing potential health risks

Commercially introduced in 1995, CDMA quickly became one of the world's fastest growing wireless technologies. In 1999, the International Telecommunications Union selected CDMA as the industry standard for new "third-generation" (3G) wireless systems. Many leading wireless carriers are now building or upgrading to 3G CDMA networks in order to provide more capacity for voice traffic, along with high-speed data capabilities.

DS_CDMA

Multiple access systems based on DS CDMA have achieved increasing significance for mobile communications applications. A promising concept is based on DS_CDMA applying MRC at the receiver. MRC takes advantage of the channel diversity to combat the multipath fading. However the capacity of a DS_CDMA system is limited by both multi-user interference and inter symbol interference ISI in high data rate applications.

OFDM is applied to combat the frequency selectivity of the channel using a simple one tap equalizer Further more OFDM prevents the ISI and inter carrier interference ICI by inserting a guard interval between adjacent OFDM symbols OFDM is typically used for audio TV and HDTV transmission over terrestrial channels and achieves high spectral efficiency.

The CMDA Technology overview

FDMA

In Frequency Division Multiple Access, the frequency band is divided in slots. Each user gets one frequency slot assigned that is used at will. It could be compared to AM or FM broadcasting radio where each station has a frequency assigned. FDMA demands good filtering.

TDMA

In Time Division Multiple Access, the frequency band is not partitioned but users are allowed to use it only in predefined intervals of time, one at a time. Thus, TDMA demands synchronization among the users.

CDMA

CDMA, for Code Division Multiple Access, is different from its traditional ways in which it does not allocate frequency or time in user slots but gives the right to use both to all users simultaneously. To do this, it uses a technique known as Spread Spectrum . In effect, each user is assigned a code,which spreads its signal bandwidth in such a way that only the same code can recover it at the receiver end. This method has the property that the unwanted signals with different codes get spread even more by the process, making them like noise to the receiver .

Spread Spectrum

Spread Spectrum is a mean of transmission where the data occupies a larger bandwidth than necessary. Bandwidth spreading is accomplished before the transmission through the use of a code, which is independent of the transmitted data. The same code is used to demodulate the data at the receiving end. The following figure illustrate the spreading done on the data signal x(t) by the spreading signal c(t) resulting in the message signal to be transmitted, m(t).

Originally for military use to avoid jamming (interference created on purpose to make a communication channel unusable), spread spectrum modulation is now used in personal communication systems for its superior performance in an interference dominated environment .

ACCESS SCHEMES

For radio systems there are two resources, frequency and time. Division by frequency, so that each pair of communicators is allocated part of the spectrum for all of the time, results in Frequency Division Multiple Access (FDMA). Division by time, so that each pair of communicators is allocated all (or at least a large part) of the spectrum for part of the time results in Time Division Multiple Access (TDMA). In Code Division Multiple Access (CDMA), every communicator will be allocated the entire spectrum all of the time. CDMA uses codes to identify connections.

Multiple Access Schemes


CODING

CDMA uses unique spreading codes to spread the baseband data before transmission. The signal is transmitted in a channel, which is below noise level. The receiver then uses a correlator to despread the wanted signal, which is passed through a narrow bandpass filter. Unwanted signals will not be despread and will not pass through the filter. Codes take the form of a carefully designed one/zero sequence produced at a much higher rate than that of the baseband data. The rate of a spreading code is referred to as chip rate rather than bit rate.

CDMA spreading

CODES

CDMA codes are not required to provide call security, but create a uniqueness to enable call identification. Codes should not correlate to other codes or time shifted version of itself. Spreading codes are noise like pseudo-random codes, channel codes are designed for maximum separation from each other and cell identification codes are balanced not to correlate to other codes of itsel

THE SPREADING PROCESS

WCDMA uses Direct Sequence spreading, where spreading process is done by directly combining the baseband information to high chip rate binary code. The Spreading Factor is the ratio of the chips (UMTS = 3.84Mchips/s) to baseband information rate. Spreading factors vary from 4 to 512 in FDD UMTS. Spreading process gain can in expressed in dBs (Spreading factor 128 = 21dB gain).

CDMA spreading

POWERCONTROL

CDMA is interference limited multiple access system. Because all users transmit on the same frequency, internal interference generated by the system is the most significant factor in determining system capacity and call quality. The transmit power for each user must be reduced to limit interference, however, the power should be enough to maintain the required Eb/No (signal to noise ratio) for a satisfactory call quality. Maximum capacity is achieved when Eb/No of every user is at the minimum level needed for the acceptable channel performance. As the MS moves around, the RF environment continuously changes due to fast and slow fading, external interference, shadowing , and other factors. The aim of the dynamic power control is to limit transmitted power on both the links while maintaining link quality under all conditions. Additional advantages are longer mobile battery life and longer life span of BTS power amplifiers

HANDOVER
Handover occurs when a call has to be passed from one cell to another as the user moves between cells. In a traditional "hard" handover, the connection to the current cell is broken, and then the connection to the new cell is made. This is known as a "break-before-make" handover. Since all cells in CDMA use the same frequency, it is possible to make the connection to the new cell before leaving the current cell. This is known as a "make-before-break" or "soft" handover. Soft handovers require less power, which reduces interference and increases capacity. Mobile can be connected to more that two BTS the handover. "Softer" handover is a special case of soft handover where the radio links that are added and removed belong to the same Node B.

CDMA soft handover

MULTIPATH AND RAKE RECEIVERS

One of the main advantages of CDMA systems is the capability of using signals that arrive in the receivers with different time delays. This phenomenon is called multipath. FDMA and TDMA, which are narrow band systems, cannot discriminate between the multipath arrivals, and resort to equalization to mitigate the negative effects of multipath. Due to its wide bandwidth and rake receivers, CDMA uses the multipath signals and combines them to make an even stronger signal at the receivers. CDMA subscriber units use rake receivers. This is essentially a set of several receivers. One of the receivers (fingers) constantly searches for different multipaths and feeds the information to the other three fingers. Each finger then demodulates the signal corresponding to a strong multipath. The results are then combined together to make the signal stronger.

Difference between TDMA vs CDMA.

TDMA is "Time Division Multiple Access", while CDMA is "Code Division Multiple Access". Both technologies achieve the same goal of better utilization of the radio spectrum by allowing multiple users to share the same physical channel, but by using different methods and that is why the three of the four words in each acronym are identical. Both allow more than one person to carry out a conversation on the same frequency without causing interference.

The two technologies differ in the way in which users share the common resource. In TDMA the channel is chopped up into sequential time slices. The data of each user is put on the channel in a round-robin fashion. In reality, only one user actually uses the channel at any given point of time, but he uses it only for short bursts. He then gives up the channel for a short duration to allow the other users to have their turn. This is similar to how a computer with just one processor runs multiple applications simultaneously.

CDMA on the other hand allows everyone to transmit at the same time. With conventional methods of modulation techniques it would hav been simply not possible. What makes CDMA to allow all users to transmit simultaneously is a special type of digital modulation called "Spread Spectrum". In this modulation technique user's stream of bits is taken and splattered them across a very wide channel in a pseudo-random fashion. The "pseudo" part is very important here as at the receiver end the randomization must be undone in order to collect the bits together in a coherent order.

For example consider a room full of couples, and each couple trying to carry on one-on-one conversations. In TDMA each couple takes their turn for talking and they keep their turns short by speaking only one sentence at a time. As there is always more one person speaking in the room at any given point of time, no one has to worry about being heard over the background din. In CDMA assume each couple talks simultaneously, but they all use different languages. The background din doesn't cause any real problem as none of the listeners understand any language other than that of the individual to whom they are listening.

Voice Encoding

At this point many people confuse two distinctly different issues involved in the transmission of digital audio. The first is the WAY in which the stream of bits is delivered from one end to the other. This part of the "air interface" is what makes one technology different from another. The second is the compression algorithm used to squeeze the audio into as small a stream of bits as possible.

This latter component is known at the "Voice Coder", or Vocoder for short. Another term commonly used is CODEC, which is a similar word to modem. It combines the terms "COder" and "DECoder". Although each technology has chosen their own unique CODECs, there is no rule saying that one transmission method needs to use a specific CODEC. People often lump a technology's transmission method with its CODEC as though they were single entities.

Voice encoding schemes differ slightly in their approach to the problem. Because of this, certain types of human voice work better with some CODECs than they do with others. The point to remember is that all PCS CODECs are compromises of some sort. Since human voices have such a fantastic range of pitch and tonal depth, one cannot expect any single compromise to handle each one equally well. This inability to cope with all types of voice at the same level does lead some people to choose one technology over another.

All of the PCS technologies try to minimize battery consumption during calls by keeping the transmission of unnecessary data to a minimum. The phone decides whether or not you are presently speaking, or if the sound it hears is just background noise. If the phone determines that there is no intelligent data to transmit it blanks the audio and it reduces the transmitter duty cycle (in the case of TDMA) or the number of transmitted bits (in the case of CDMA). When the audio is blanked your caller would suddenly find themselves listening to "dead air", and this may cause them to think the call has dropped.

To avoid this psychological problem many service providers insert what is known as "Comfort Noise" during the blanked periods. Comfort Noise is synthesized white noise that tries to mimic the volume and structure of the real background noise. This fake background noise assures the caller that the connection is alive and well.

However, in newer CODECs such as EVRC (used exclusively on CDMA systems) the background noise is generally suppressed even while the user is talking. This piece of magic makes it sound as though the cell phone user is not in a noisy environment at all. Under these conditions, Comfort Noise is neither necessary, nor desirable.

DS-CDMA-INTRODUCTION

While multiple access interference (MAI) by other users has been recognized as the capacity-limiting factor in direct sequence code-division multiple-access (DS-CDMA)-based cellular communication systems, multiuser approaches have largely alleviated the problem when the noise process is additive Gaussian. With the availability of multiuser detectors, inaccurate or inappropriate noise modelling assumptions seem to have become the issue again.

Whereas multiuser detection has much to offer in the mobile- to-base station uplink, it does not at present appear to be feasible for the downlink due to the complexity involved and the

lack of resistance against adjacent cell interference. Moreover, the few multiuser proposals for the downlink require the knowledge of all spreading codes, which is not possible in the tactical military environment, for instance. Enhanced single-user receivers equipped with adaptive filter banks deliver promising performance with reasonable complexity, especially

in slowly varying channels. Thus, the performance of single-user detectors is still of interest, particularly in the presence of non-Gaussian noise. In both urban outdoor and indoor mobile radio environments, electromagnetic interference generated by man-made sources such as factories or power lines causes the noise to be of non-Gaussian nature. Large noise magnitudes are deemed very improbable by linear receivers, and consequently performance deterioration is experienced. It is therefore desirable to build systems that can maintain respectable functionality under a broad class of noise distributions, rather than strictly optimizing for the unrealistic Gaussian assumption. Such is the goal of robust detection and estimation theory, which aims to design systems that are suboptimal under nominal channel conditions (e.g., Gaussian channel) and yet do not face catastrophy when the noise distribution is not nominal (e.g., unlike linear schemes). Note that suboptimality here refers

to very good performance that is slightly worse than that of the nominal-optimal detector/estimator.

The direct sequence code division multiple access (DS-CDMA) technique has been favourably considered for application in digital mobile cellular networks due to its potential to provide higher system capacity over conventional multiple access techniques. Unlike FDMA and TDMA capacities which are mostly limited by the bandwidth, the capacity of a CDMA system is mainly restricted by its interference level. Any reduction in interference produces a direct and linear increase in system capacity. Multiple access interference (MAI) caused by non-zero cross-correlation between different spreading sequences is the major type of interference limiting the CDMA system capacity. Much work has been done to characterize MAI, and to analyze and evaluate the CDMA system performance in the presence of MAI. Since the cross-correlation properties of most sets of spreading codes are either too complex to analyze or very difficult to compute when different transmissions are not synchronized, a random sequence model. In the case of moderate to large processing gains, Gaussian distribution with variable variance is a good approximation for the MAI distribution. One of the approaches to reduce MAI is to employ orthogonal spreading sequences, and try to synchronize the transmissions at the chip level (quasi-synchronization). However, this is generally difficult to achieve in multipoint-to-point systems, such as the reverse link (mobile-to-base) of a cellular system, due to a lack of synchronization of the various mobile terminals, and the variable transmission delays. In this paper, a multi-carrier DS-CDMA (MCDS-CDMA) scheme is employed to facilitate the synchronization process, and thus reduce MAI.

SYSTEM MODEL

A model of the MS-DS-CDMA system for the kth user of a CDMA system is shown in the figure 1.

TRANMSITTER MODEL

At the transmitter the user‘s data stream dk(t) is divided into M interleaved sub streams and spread by a spreading sequence ck(t) to a fraction 1/M of the entire transmission bandwidth W. The resultant chip sequences are then used to modulate M carrier. The carrier frequencies ωm,m=1,2,...M are equally spaced by the chip rate so that they are mutually orthogonal over one channel symbol interval T. Let R be the information rate and Rc be the carrier control code rate then the channel symbol interval is

The data encoder is often crucial for performance of channels .The ned for interleaver depends on the channel characteristics and the multi-carrier scheme. For BPSK modulation scheme

The chip time is

They are uniformly distributed over (0,2Pi).

CHANNEL MODEL:

The entire Bandwidth available for multicarrier transmission is much larger than the data rate. The channel is modelled for complex impulse response.

αk ,l -path amplitude

ςk,l-delay spread

∆fc-band width

A practical DS spectrum occupies a bandwidth much larger than ∆fc .

In MC-DS-CDMA system data are transmitted over parallel channels with bandwidth equal to fraction of W. The impulse response of sub channel is

Based on this model narrow band multi carrier schemes compared.

The channel output is

n(t)-AWGN( additive white Gaussian noise).

The time between sub-streams results from synchronization error and multi path delay.

RECEIVER MODEL:

There are M branches in the receiver with each detecting the data substream from one sub channel .we are concerned with first sub channel .The time variation of fading is slow enough that the arrival time and phase of the desired signal can be acquired .The output of the low pass filter at the sampling point is Imo, Jmo-MAI components from inside and outside functions of noise and so Soft decision is decoded serially and performed for channel fading.

BER PERFORMANCE:

MC-DS-CDMA system performance measured by bit error rate through analysis and simulation.

Analysis:

The BER is analysed based on the following:

  1. Ortoganal spreading sequences with rectangular pulse shape are applied.
  2. ζk,k=1…K are independent of random variables distributd in (-ζD,ζD) WHERE ζD=εD+ςD.Given W and ζD,M is chosen so that ζD<=TC.
  3. It is assumed that the fading parameters of the desired user .

It is perfectly estimated so that the coherent detection and optimum soft decision decoding could be carried out at the receiver to make the problem analytically tractable. The fading amplitudes as independent Rayleigh random variables with equal second moments. The model is

Where N is spread spectrum processing gain

N=T/Tc .

The orthogonal spreading sequence is given by

For 0<n<N-1;

It is difficult to analyze the cross correlation properties of most practically used spreading sequence. In case of sequences with long period the sequence may be modeled as Bernouli process for the purpose of analysis. The correlation term is sum of +1 or -1 terms. When Nis moderate to large we may invoke the central limit theorem and model each term in the sum of as having a Gaussian distribution conditioned .The distribution has Zero man and the variance.

Which is a variable.

Where

Which is the received signal power P is constant for every signal stream when power control is assumed.

Is normalized range of time offset. It is seen that Imo does not depend on m0,.so m0 will be omitted in the sequel, and the average variance of I will be simply denoted as VI.

We can approximate this with Gaussian distribution

The average is given by

The optimum decoder combines the LPF output and forms Nc decision variables

Where Cij denotes the bit in the jth position of the ith code word ,mij denotes the sub channel number for the transmitting cij and Nc the total number of code words.assuming the code word c1 is transmitted for correct decoding,U1 must exceed all other decision variable Ui,i=2,3…,Nc.Let Si={j:C1J≠Cij}.

Instead of attempting to derive the exact error probability, we resort to a union bound. Let Pi =P(µi<0) Which is the probability of C1 being decoded Ci.

Pi depends not only on the hamming distance between C1 and C2 but also on the position of sub channels over which these different bits are transmitted because V is a function of m0.From the system performance point we need average error probability. To find the average decoded error probability we replace the term V by it is average.

The Hamming distance dmin is assumed between every pair of code words. For orthogonal codes like the Reed Muller (RM) code used in this scheme, the equal distance assumption turns out to be exact.

Mean is

Variance is

Conditional probability of error is

We are concerned with average system BER over a long period of transmission, the average interference variances VI and Vj are used in expressing average effect of the interference on the system performance. To find the unconditional error probability pi We need to find the PDF.

The PDF is

This is the average signal to noise plus interference ratio(SINR) per sub channel which can be further displayed as

Where SIR is defined as the average signal to interference ratio per sub channel

The closed form of solution

Probability for the function is

MATLAB INTRODUCTION:

Matlab is a commercial "Matrix Laboratory" package which operates as an interactive programming environment. It is a mainstay of the Mathematics Department software lineup and is also available for PC's and Macintoshes and may be found on the CIRCA VAXes. Matlab is well adapted to numerical experiments since the underlying algorithms for Matlab's builtin functions and supplied m-files are based on the standard libraries LINPACK and EISPACK.

Matlab program and script files always have filenames ending with ".m"; the programming language is exceptionally straightforward since almost every data object is assumed to be an array. Graphical output is available to supplement numerical results.

IMREAD Read image from graphics file.

A = IMREAD(FILENAME,FMT) reads a grayscale or color image from the file

specified by the string FILENAME. If the file is not in the current directory, or in a directory on the MATLAB path, specify the full pathname. The text string FMT specifies the format of the file by its standard file extension. For example, specify 'gif' for Graphics Interchange Format files. To see a list of supported formats, with their file extensions, use the IMFORMATS function. If IMREAD cannot find a file named FILENAME, it looks for a file named FILENAME.FMT.

IMFINFO Information about graphics file.

INFO = IMFINFO(FILENAME,FMT) returns a structure whose fields contain information about an image in a graphics file. FILENAME is a string that specifies the name of the graphics file, and FMT is a string that specifies the format of the file. The file must be in the current directory or in a directory on the MATLAB path. If IMFINFO cannot find a file named FILENAME, it looks for a file named FILENAME.FMT.

IMWRITE Write image to graphics file.

IMWRITE(A,FILENAME,FMT) writes the image A to the file specified by

FILENAME in the format specified by FMT.

A can be an M-by-N (grayscale image) or M-by-N-by-3 (color image) array. A cannot be an empty array. If the format specified is TIFF, IMWRITE can also accept an M-by-N-by-4 array containing color data that uses the CMYK color space.

FILENAME is a string that specifies the name of the file.

SIZE Size of array.

D = SIZE(X), for M-by-N matrix X, returns the two-element row vector D = [M,N] containing the number of rows and columns in the matrix. For N-D arrays, SIZE(X) returns a 1-by-N vector of dimension lengths. Trailing singleton dimensions are ignored.

[M,N] = SIZE(X) for matrix X, returns the number of rows and columns in

X as separate output variables.

IMSHOW Display image in Handle Graphics figure.

IMSHOW (I) displays the grayscale image I. IMSHOW(I,[LOW HIGH]) displays the grayscale image I, specifying the display range for I in [LOW HIGH]. The value LOW (and any value less than LOW) displays as black, the value HIGH (and any value greater than HIGH) displays as white. Values in between are displayed as intermediate shades of gray, using the default number of gray levels. If you use an empty matrix ([]) for [LOW HIGH], IMSHOW uses [min(I(:)) max(I(:))]; that is, the minimum value in I is displayed as black, and the maximum value is displayed as white.

MEAN Average or mean value.

For vectors, MEAN(X) is the mean value of the elements in X. For matrices, MEAN(X) is a row vector containing the mean value of each column. For N-D arrays, MEAN(X) is the mean value of the elements along the first non-singleton dimension of X.

MIN Smallest component.

For vectors, MIN(X) is the smallest element in X. For matrices, MIN(X) is a row vector containing the minimum element from each column. For N-D arrays, MIN(X) operates along the first non-singleton dimension.

MAX Largest component.

For vectors, MAX(X) is the largest element in X. For matrices, MAX(X) is a row vector containing the maximum element from each column. For N-D arrays, MAX(X) operates along the first non-singleton dimension.

DOUBLE Convert to double precision.

DOUBLE(X) returns the double precision value for X. If X is already a double precision array, DOUBLE has no effect.

DOUBLE is called for the expressions in FOR, IF, and WHILE loops if the expression isn't already double precision. DOUBLE should be overloaded for all objects where it makes sense to convert it into a double precision value.

RAND Uniformly distributed pseudo-random numbers.

R = RAND(N) returns an N-by-N matrix containing pseudo-random values drawn from a uniform distribution on the unit interval.

RAND(M,N) or RAND([M,N]) returns an M-by-N matrix.

RAND(M,N,P,...) or RAND([M,N,P,...]) returns an M-by-N-by-P-by-... array.

RAND with no arguments returns a scalar.

RAND(SIZE(A)) returns an array the same size as A.

PROGRAM

clear all;

close all;

clc;

%%

no_of_user=40;

no_of_sub =8;

N=10^3;

%%

length_mess=no_of_user*N;

walsh=hadamard(no_of_sub);

kux=1;

for ku=1:no_of_user

code{ku}=walsh(kux,:);

kux=kux+1;

if(kux==no_of_sub)

kux=1;

end

end

n = 6; k = 4; % Set codeword length and message length % for a [6,4] code.

%%

original_message=randint(1,length_mess,2);

locx=1;

locy=N;

for ku=1:no_of_user

data{ku}= original_message(locx:locy);

msg=data{ku};

mess= encode(msg,n,k,'cyclic'); % Code will be a binary column.

len=length(mess);

ele{ku}=randperm(len);

intr_lve{ku}=intrlv(mess,ele{ku})

datamod = 2*intr_lve{ku}-1;

user_data_mod{ku}=datamod';

locx=locy+1

locy=locx+(N-1)

end

%%

for ku=1:no_of_user

data_user11=user_data_mod{ku};

spdata1_user1=data_user11*(code{ku});

spdata12=(spdata1_user1)';

ifftdata_user1=ifft(spdata12);

ifftdata12=ifftdata_user1';

y1=[ifftdata12(:,[(no_of_sub-2):no_of_sub]) ifftdata12];

transdata1=y1';

tx_user=transdata1;

sp_data{ku}=tx_user;

end

%%

tx_data_final=zeros(size(sp_data{1}));

for ku=1:no_of_user

tx_data_final=tx_data_final+sp_data{ku};

end

%%

for ku=2:no_of_user

N1=N*(n/k);

Taps=4;

p1=0.5/2.3;

p2=0.9/2.3;

p3=0.7/2.3;

p4=0.2/2.3;

gain1=sqrt(p1/2)*[randn(1,N1) + j*randn(1,N1)];

gain2=sqrt(p2/2)*[randn(1,N1) + j*randn(1,N1)];

gain3=sqrt(p3/2)*[randn(1,N1) + j*randn(1,N1)];

gain4=sqrt(p4/2)*[randn(1,N1) + j*randn(1,N1)];

tx_data_final=sp_data{ku-1}+sp_data{ku};

x11=tx_data_final(:);

x12=reshape(x11,1,length(x11));

i=1:length(x12);

%%

delay1=1;

for i=delay1+1:length(x12)

x13(i)=tx_data_final(i-delay1);

end

delay2=2;

for i=delay2+1:length(x12)

x14(i)=tx_data_final(i-delay2);

end

delay3=3;

for i=delay3+1:length(x12)

x15(i)=tx_data_final(i-delay3);

end

x1=reshape(x13,(no_of_sub+3),length(x13)/(no_of_sub+3));

x2=reshape(x14,(no_of_sub+3),length(x14)/(no_of_sub+3));

x3=reshape(x15,(no_of_sub+3),length(x15)/(no_of_sub+3));

ch1=repmat(gain1,(no_of_sub+3),1);

ch2=repmat(gain2,(no_of_sub+3),1);

ch3=repmat(gain3,(no_of_sub+3),1);

ch4=repmat(gain4,(no_of_sub+3),1);

data_channel=(tx_data_final).*ch1+x1.*ch2+x2.*ch3+x3.*ch4;

data_noise1=data_channel(:);

data_noise2=reshape(data_noise1,1,length(data_noise1));

end

%%

noise = 1/sqrt(2)*[randn(1,length(data_noise2)) + j*randn(1,length(data_noise2))];

snr = [0:2:8];

for i = 1:length(snr)

y = data_noise2 + (sqrt(1)*10^(-snr(i)/20))*noise; %Addition of Noise

data_received =y;

rx1=reshape(data_received,(no_of_sub+3),length(data_received)/(no_of_sub+3));

rx12=rx1';

rx13 = rx12(:,[(4:(no_of_sub+3))]);

rx14=rx13';

fft_data_received =fft(rx14);

channel_response=fft([gain1;gain2;gain3;gain4],no_of_sub);

data_equilized=fft_data_received.*conj(channel_response);

ku=no_of_user;

recdata11=(data_equilized'*(code{ku})')';

recdata12=real(recdata11)>0;

mess1=deintrlv(uint8(recdata12),ele{ku})

out_data= decode(double(mess1),n,k,'cyclic'); % Code will be a binary column.

errors_user1= size(find([data{ku}- out_data]),2);

bit_error_rate(i)= errors_user1/N;

end

%% 70

no_of_user=70;

no_of_sub =8;

N=10^3;

%%

length_mess=no_of_user*N;

walsh=hadamard(no_of_sub);

kux=1;

for ku=1:no_of_user

code{ku}=walsh(kux,:);

kux=kux+1;

if(kux==no_of_sub)

kux=1;

end

end

n = 6; k = 4; % Set codeword length and message length % for a [6,4] code.

%%

original_message=randint(1,length_mess,2);

locx=1;

locy=N;

for ku=1:no_of_user

data{ku}= original_message(locx:locy);

msg=data{ku};

mess= encode(msg,n,k,'cyclic'); % Code will be a binary column.

len=length(mess);

ele{ku}=randperm(len);

intr_lve{ku}=intrlv(mess,ele{ku})

datamod = 2*intr_lve{ku}-1;

user_data_mod{ku}=datamod';

locx=locy+1

locy=locx+(N-1)

end

%%

for ku=1:no_of_user

data_user11=user_data_mod{ku};

spdata1_user1=data_user11*(code{ku});

spdata12=(spdata1_user1)';

ifftdata_user1=ifft(spdata12);

ifftdata12=ifftdata_user1';

y1=[ifftdata12(:,[(no_of_sub-2):no_of_sub]) ifftdata12];

transdata1=y1';

tx_user=transdata1;

sp_data{ku}=tx_user;

end

%%

tx_data_final=zeros(size(sp_data{1}));

for ku=1:no_of_user

tx_data_final=tx_data_final+sp_data{ku};

end

%%

for ku=2:no_of_user

N1=N*(n/k);

Taps=4;

p1=0.5/2.3;

p2=0.9/2.3;

p3=0.7/2.3;

p4=0.2/2.3;

gain1=sqrt(p1/2)*[randn(1,N1) + j*randn(1,N1)];

gain2=sqrt(p2/2)*[randn(1,N1) + j*randn(1,N1)];

gain3=sqrt(p3/2)*[randn(1,N1) + j*randn(1,N1)];

gain4=sqrt(p4/2)*[randn(1,N1) + j*randn(1,N1)];

tx_data_final=sp_data{ku-1}+sp_data{ku};

x11=tx_data_final(:);

x12=reshape(x11,1,length(x11));

i=1:length(x12);

%%

delay1=1;

for i=delay1+1:length(x12)

x13(i)=tx_data_final(i-delay1);

end

delay2=2;

for i=delay2+1:length(x12)

x14(i)=tx_data_final(i-delay2);

end

delay3=3;

for i=delay3+1:length(x12)

x15(i)=tx_data_final(i-delay3);

end

x1=reshape(x13,(no_of_sub+3),length(x13)/(no_of_sub+3));

x2=reshape(x14,(no_of_sub+3),length(x14)/(no_of_sub+3));

x3=reshape(x15,(no_of_sub+3),length(x15)/(no_of_sub+3));

ch1=repmat(gain1,(no_of_sub+3),1);

ch2=repmat(gain2,(no_of_sub+3),1);

ch3=repmat(gain3,(no_of_sub+3),1);

ch4=repmat(gain4,(no_of_sub+3),1);

data_channel=(tx_data_final).*ch1+x1.*ch2+x2.*ch3+x3.*ch4;

data_noise1=data_channel(:);

data_noise2=reshape(data_noise1,1,length(data_noise1));

end

%%

noise = 1/sqrt(2)*[randn(1,length(data_noise2)) + j*randn(1,length(data_noise2))];

snr = [0:2:8];

for i = 1:length(snr)

y = data_noise2 + (sqrt(1)*10^(-snr(i)/20))*noise; %Addition of Noise

data_received =y;

rx1=reshape(data_received,(no_of_sub+3),length(data_received)/(no_of_sub+3));

rx12=rx1';

rx13 = rx12(:,[(4:(no_of_sub+3))]);

rx14=rx13';

fft_data_received =fft(rx14);

channel_response=fft([gain1;gain2;gain3;gain4],no_of_sub);

data_equilized=fft_data_received.*conj(channel_response);

ku=no_of_user;

recdata11=(data_equilized'*(code{ku})')';

recdata12=real(recdata11)>0;

mess1=deintrlv(uint8(recdata12),ele{ku})

out_data= decode(double(mess1),n,k,'cyclic'); % Code will be a binary column.

errors_user1= size(find([data{ku}- out_data]),2);

bit_error_rate1(i)= errors_user1/N;

end

%% SC

n=6;k=4;

N1 = 10^4;

no_of_user=40;

for ku=1:no_of_user

ip1{ku} = rand(1,N1)>0.5;

end

ip=cell2mat(ip1);

ip2=encode(double(ip),n,k,'cyclic');

loc=randperm(length(ip2));

ip3=intrlv(ip2,loc);

s = 2*ip3-1;

N=length(s);

Eb_N0_dB = [0:2:8];

no_of_sub=6;

for jj = 1:length(no_of_sub)

for ii = 1:length(Eb_N0_dB)

n1 = 1/sqrt(2)*[randn(no_of_sub(jj),N) + j*randn(no_of_sub(jj),N)];

h = 1/sqrt(2)*[randn(no_of_sub(jj),N) + j*randn(no_of_sub(jj),N)];

sD = kron(ones(no_of_sub(jj),1),s);

y = h.*sD + 10^(-Eb_N0_dB(ii)/20)*n1;

yHat = y.*exp(-j*angle(h));

yHat = sum(yHat,1);

ipHat = real(yHat)>0;

ipde1=deintrlv(uint8(ipHat),loc);

ipde3=decode((ipde1),n,k,'cyclic');

nErr(jj,ii) = size(find([ip- ipde3]),2);

end

end

bit_error_rate2 = nErr/N;

%% 70

n=6;k=4;

N1 = 10^4;

no_of_user=70;

for ku=1:no_of_user

ip1{ku} = rand(1,N1)>0.5;

end

ip=cell2mat(ip1);

ip2=encode(double(ip),n,k,'cyclic');

loc=randperm(length(ip2));

ip3=intrlv(ip2,loc);

s = 2*ip3-1;

N=length(s);

Eb_N0_dB = [0:2:8];

no_of_sub=6;

for jj = 1:length(no_of_sub)

for ii = 1:length(Eb_N0_dB)

n1 = 1/sqrt(2)*[randn(no_of_sub(jj),N) + j*randn(no_of_sub(jj),N)];

h = 1/sqrt(2)*[randn(no_of_sub(jj),N) + j*randn(no_of_sub(jj),N)];

sD = kron(ones(no_of_sub(jj),1),s);

y = h.*sD + 10^(-Eb_N0_dB(ii)/20)*n1;

yHat = y.*exp(-j*angle(h));

yHat = sum(yHat,1);

ipHat = real(yHat)>0;

ipde1=deintrlv(double(ipHat),loc);

ipde3=decode(ipde1,n,k,'cyclic');

nErr(jj,ii) = size(find([ip- ipde3]),2);

end

end

bit_error_rate3 = nErr/N;

figure,semilogy(snr,bit_error_rate,'r*:',snr,bit_error_rate1,'g>:',snr,bit_error_rate2,'ys-',snr,bit_error_rate3,'kd-','linewidth',2);

legend('40 user MC CDMA ','70 user MC CDMA','40 user SC CDMA ','70 user SC CDMA');

title('performance');

xlabel('SNR value');

ylabel('bit error rate');

grid on;

clear all;

close all;

clc;

%%

no_of_user=70;

no_of_sub =8;

N=10^3;

%%

length_mess=no_of_user*N;

walsh1=hadamard(no_of_sub);

walsh=REEDMULER(walsh1);

kux=1;

for ku=1:no_of_user

code{ku}=walsh(kux,:);

kux=kux+1;

if(kux==no_of_sub)

kux=1;

end

end

n = 6; k = 4; % Set codeword length and message length % for a [6,4] code.

%%

original_message=randint(1,length_mess,2);

locx=1;

locy=N;

for ku=1:no_of_user

data{ku}= original_message(locx:locy);

datamod = 2*data{ku}-1;

user_data_mod{ku}=datamod';

locx=locy+1

locy=locx+(N-1)

end

%%

for ku=1:no_of_user

data_user11=user_data_mod{ku};

spdata1_user1=data_user11*(code{ku});

spdata12=(spdata1_user1)';

ifftdata_user1=ifft(spdata12);

ifftdata12=ifftdata_user1';

y1=[ifftdata12(:,[(no_of_sub-2):no_of_sub]) ifftdata12];

transdata1=y1';

tx_user=transdata1;

sp_data{ku}=tx_user;

end

%%

tx_data_final=zeros(size(sp_data{1}));

for ku=1:no_of_user

tx_data_final=tx_data_final+sp_data{ku};

end

%%

for ku=2:no_of_user

N1=N;

Taps=4;

p1=0.5/2.3;

p2=0.9/2.3;

p3=0.7/2.3;

p4=0.2/2.3;

gain1=sqrt(p1/2)*[randn(1,N1) + j*randn(1,N1)];

gain2=sqrt(p2/2)*[randn(1,N1) + j*randn(1,N1)];

gain3=sqrt(p3/2)*[randn(1,N1) + j*randn(1,N1)];

gain4=sqrt(p4/2)*[randn(1,N1) + j*randn(1,N1)];

tx_data_final=sp_data{ku-1}+sp_data{ku};

x11=tx_data_final(:);

x12=reshape(x11,1,length(x11));

i=1:length(x12);

%%

delay1=1;

for i=delay1+1:length(x12)

x13(i)=tx_data_final(i-delay1);

end

delay2=2;

for i=delay2+1:length(x12)

x14(i)=tx_data_final(i-delay2);

end

delay3=3;

for i=delay3+1:length(x12)

x15(i)=tx_data_final(i-delay3);

end

x1=reshape(x13,(no_of_sub+3),length(x13)/(no_of_sub+3));

x2=reshape(x14,(no_of_sub+3),length(x14)/(no_of_sub+3));

x3=reshape(x15,(no_of_sub+3),length(x15)/(no_of_sub+3));

ch1=repmat(gain1,(no_of_sub+3),1);

ch2=repmat(gain2,(no_of_sub+3),1);

ch3=repmat(gain3,(no_of_sub+3),1);

ch4=repmat(gain4,(no_of_sub+3),1);

data_channel=(tx_data_final).*ch1+x1.*ch2+x2.*ch3+x3.*ch4;

data_noise1=data_channel(:);

data_noise2=reshape(data_noise1,1,length(data_noise1));

end

%%

noise = 1/sqrt(2)*[randn(1,length(data_noise2)) + j*randn(1,length(data_noise2))];

snr = [0:2:8];

for i = 1:length(snr)

y = data_noise2 + (sqrt(1)*10^(-snr(i)/20))*noise; %Addition of Noise

data_received =y;

rx1=reshape(data_received,(no_of_sub+3),length(data_received)/(no_of_sub+3));

rx12=rx1';

rx13 = rx12(:,[(4:(no_of_sub+3))]);

rx14=rx13';

fft_data_received =fft(rx14);

channel_response=fft([gain1;gain2;gain3;gain4],no_of_sub);

data_equilized=fft_data_received.*conj(channel_response);

ku=no_of_user;

recdata11=(data_equilized'*(code{ku})')';

recdata12=real(recdata11)>0;

out_data=recdata12;

errors_user1= size(find([data{ku}- out_data]),2);

bit_error_rate(i)= errors_user1/N;

end

%% 70

no_of_user=70;

no_of_sub =8;

N=10^3;

%%

length_mess=no_of_user*N;

walsh1=hadamard(no_of_sub);

walsh=REEDMULER(walsh1);

kux=1;

for ku=1:no_of_user

code{ku}=walsh(kux,:);

kux=kux+1;

if(kux==no_of_sub)

kux=1;

end

end

n = 6; k = 4; % Set codeword length and message length % for a [6,4] code.

%%

original_message=randint(1,length_mess,2);

locx=1;

locy=N;

for ku=1:no_of_user

data{ku}= original_message(locx:locy);

msg=data{ku};

mess= encode(msg,n,k,'cyclic'); % Code will be a binary column.

len=length(mess);

ele{ku}=randperm(len);

intr_lve{ku}=intrlv(mess,ele{ku})

datamod = 2*intr_lve{ku}-1;

user_data_mod{ku}=datamod';

locx=locy+1

locy=locx+(N-1)

end

%%

for ku=1:no_of_user

data_user11=user_data_mod{ku};

spdata1_user1=data_user11*(code{ku});

spdata12=(spdata1_user1)';

ifftdata_user1=ifft(spdata12);

ifftdata12=ifftdata_user1';

y1=[ifftdata12(:,[(no_of_sub-2):no_of_sub]) ifftdata12];

transdata1=y1';

tx_user=transdata1;

sp_data{ku}=tx_user;

end

%%

tx_data_final=zeros(size(sp_data{1}));

for ku=1:no_of_user

tx_data_final=tx_data_final+sp_data{ku};

end

%%

for ku=2:no_of_user

N1=N*(n/k);

Taps=4;

p1=0.5/2.3;

p2=0.9/2.3;

p3=0.7/2.3;

p4=0.2/2.3;

gain1=sqrt(p1/2)*[randn(1,N1) + j*randn(1,N1)];

gain2=sqrt(p2/2)*[randn(1,N1) + j*randn(1,N1)];

gain3=sqrt(p3/2)*[randn(1,N1) + j*randn(1,N1)];

gain4=sqrt(p4/2)*[randn(1,N1) + j*randn(1,N1)];

tx_data_final=sp_data{ku-1}+sp_data{ku};

x11=tx_data_final(:);

x12=reshape(x11,1,length(x11));

i=1:length(x12);

%%

delay1=1;

for i=delay1+1:length(x12)

x13(i)=tx_data_final(i-delay1);

end

delay2=2;

for i=delay2+1:length(x12)

x14(i)=tx_data_final(i-delay2);

end

delay3=3;

for i=delay3+1:length(x12)

x15(i)=tx_data_final(i-delay3);

end

x1=reshape(x13,(no_of_sub+3),length(x13)/(no_of_sub+3));

x2=reshape(x14,(no_of_sub+3),length(x14)/(no_of_sub+3));

x3=reshape(x15,(no_of_sub+3),length(x15)/(no_of_sub+3));

ch1=repmat(gain1,(no_of_sub+3),1);

ch2=repmat(gain2,(no_of_sub+3),1);

ch3=repmat(gain3,(no_of_sub+3),1);

ch4=repmat(gain4,(no_of_sub+3),1);

data_channel=(tx_data_final).*ch1+x1.*ch2+x2.*ch3+x3.*ch4;

data_noise1=data_channel(:);

data_noise2=reshape(data_noise1,1,length(data_noise1));

end

%%

noise = 1/sqrt(2)*[randn(1,length(data_noise2)) + j*randn(1,length(data_noise2))];

snr = [0:2:8];

for i = 1:length(snr)

y = data_noise2 + (sqrt(1)*10^(-snr(i)*i/20))*noise; %Addition of Noise

data_received =y;

rx1=reshape(data_received,(no_of_sub+3),length(data_received)/(no_of_sub+3));

rx12=rx1';

rx13 = rx12(:,[(4:(no_of_sub+3))]);

rx14=rx13';

fft_data_received =fft(rx14);

channel_response=fft([gain1;gain2;gain3;gain4],no_of_sub);

data_equilized=fft_data_received.*conj(channel_response);

ku=no_of_user;

recdata11=(data_equilized'*(code{ku})')';

recdata12=real(recdata11)>0;

mess1=deintrlv(uint8(recdata12),ele{ku})

out_data= decode(double(mess1),n,k,'cyclic'); % Code will be a binary column.

errors_user1= size(find([data{ku}- out_data]),2);

bit_error_rate1(i)= errors_user1/(N*i);

end

%% SC

n=6;k=4;

N1 = 10^4;

no_of_user=70;

for ku=1:no_of_user

ip1{ku} = rand(1,N1)>0.5;

end

ip=cell2mat(ip1);

s = 2*ip-1;

N=length(s);

Eb_N0_dB = [0:2:8];

no_of_sub=6;

for jj = 1:length(no_of_sub)

for ii = 1:length(Eb_N0_dB)

n = 1/sqrt(2)*[randn(no_of_sub(jj),N) + j*randn(no_of_sub(jj),N)];

h = 1/sqrt(2)*[randn(no_of_sub(jj),N) + j*randn(no_of_sub(jj),N)];

sD = kron(ones(no_of_sub(jj),1),s);

y = h.*sD + 10^(-Eb_N0_dB(ii)/20)*n;

yHat = y.*exp(-j*angle(h));

yHat = sum(yHat,1);

ipHat = real(yHat)>0;

nErr(jj,ii) = size(find([ip- ipHat]),2);

end

end

bit_error_rate2 = nErr/N;

%% 70

nn=6;kk=4;

N1 = 10^4;

no_of_user=70;

for ku=1:no_of_user

ip1{ku} = randint(1,N1,2);

end

ip=cell2mat(ip1);

ip2=encode(ip,nn,kk,'cyclic');

loc=randperm(length(ip2));

ip3=intrlv(ip2,loc);

s = 2*ip3-1;

N=length(s);

Eb_N0_dB = [0:2:8];

no_of_sub=6;

for jj = 1:length(no_of_sub)

for ii = 1:length(Eb_N0_dB)

n = 1/sqrt(2)*[randn(no_of_sub(jj),N) + j*randn(no_of_sub(jj),N)];

h = 1/sqrt(2)*[randn(no_of_sub(jj),N) + j*randn(no_of_sub(jj),N)];

sD = kron(ones(no_of_sub(jj),1),s);

y = h.*sD + 10^(-Eb_N0_dB(ii)/20)*n;

yHat = y.*exp(-j*angle(h));

yHat = sum(yHat,1);

ipHat = real(yHat)>0;

ipde1=deintrlv(uint8(ipHat),loc);

ipde3=decode((ipde1),nn,kk,'cyclic');

nErr(jj,ii) = size(find([ip- ipde3]),2);

end

end

bit_error_rate3 = nErr/N;

figure,semilogy(snr,bit_error_rate,'r*:',snr,bit_error_rate1,'k<-.',snr,bit_error_rate2,'g>-',snr,bit_error_rate3,'ms:','linewidth',2);

legend('70 user MC CDMA without code ','70 user MC CDMA with','70 user SC CDMA without code','70 user SC CDMA with code');

title('performance');

xlabel('SNR value');

ylabel('bit error rate');

grid on;

%% 70

no_of_user=70;

no_of_sub =8;

N=10^3;

fs = N/2;

t = -5:1/fs:5;

pulse_rectvalue = rectpuls(t,20e-6);

pulse_value=pulse_rectvalue(1:N);

%%

length_mess=no_of_user*N;

walsh1=hadamard(no_of_sub);

walsh=REEDMULER(walsh1);

kux=1;

for ku=1:no_of_user

code{ku}=walsh(kux,:);

kux=kux+1;

if(kux==no_of_sub)

kux=1;

end

end

n = 6; k = 4; % Set codeword length and message length % for a [6,4] code.

%%

original_message=randint(1,length_mess,2);

locx=1;

locy=N;

for ku=1:no_of_user

data{ku}= original_message(locx:locy);

msg=double(xor(data{ku},pulse_value));

mess= encode((msg),n,k,'cyclic'); % Code will be a binary column.

len=length(mess);

ele{ku}=randperm(len);

intr_lve{ku}=intrlv(mess,ele{ku})

datamod = 2*intr_lve{ku}-1;

user_data_mod{ku}=datamod';

locx=locy+1

locy=locx+(N-1)

end

%%

for ku=1:no_of_user

data_user11=user_data_mod{ku};

spdata1_user1=data_user11*(code{ku});

spdata12=(spdata1_user1)';

ifftdata_user1=ifft(spdata12);

ifftdata12=ifftdata_user1';

y1=[ifftdata12(:,[(no_of_sub-2):no_of_sub]) ifftdata12];

transdata1=y1';

tx_user=transdata1;

sp_data{ku}=tx_user;

end

%%

tx_data_final=zeros(size(sp_data{1}));

for ku=1:no_of_user

tx_data_final=tx_data_final+sp_data{ku};

end

%%

for ku=2:no_of_user

N1=N*(n/k);

Taps=4;

p1=0.5/2.3;

p2=0.9/2.3;

p3=0.7/2.3;

p4=0.2/2.3;

gain1=sqrt(p1/2)*[randn(1,N1) + j*randn(1,N1)];

gain2=sqrt(p2/2)*[randn(1,N1) + j*randn(1,N1)];

gain3=sqrt(p3/2)*[randn(1,N1) + j*randn(1,N1)];

gain4=sqrt(p4/2)*[randn(1,N1) + j*randn(1,N1)];

tx_data_final=sp_data{ku-1}+sp_data{ku};

x11=tx_data_final(:);

x12=reshape(x11,1,length(x11));

i=1:length(x12);

%%

delay1=1;

for i=delay1+1:length(x12)

x13(i)=tx_data_final(i-delay1);

end

delay2=2;

for i=delay2+1:length(x12)

x14(i)=tx_data_final(i-delay2);

end

delay3=3;

for i=delay3+1:length(x12)

x15(i)=tx_data_final(i-delay3);

end

x1=reshape(x13,(no_of_sub+3),length(x13)/(no_of_sub+3));

x2=reshape(x14,(no_of_sub+3),length(x14)/(no_of_sub+3));

x3=reshape(x15,(no_of_sub+3),length(x15)/(no_of_sub+3));

ch1=repmat(gain1,(no_of_sub+3),1);

ch2=repmat(gain2,(no_of_sub+3),1);

ch3=repmat(gain3,(no_of_sub+3),1);

ch4=repmat(gain4,(no_of_sub+3),1);

data_channel=(tx_data_final).*ch1+x1.*ch2+x2.*ch3+x3.*ch4;

data_noise1=data_channel(:);

data_noise2=reshape(data_noise1,1,length(data_noise1));

end

%%

noise = 1/sqrt(2)*[randn(1,length(data_noise2)) + j*randn(1,length(data_noise2))];

snr = [0:1:18];

for i = 1:length(snr)

y = data_noise2 + (sqrt(1)*10^(-snr(i)/20))*noise; %Addition of Noise

data_received =y;

rx1=reshape(data_received,(no_of_sub+3),length(data_received)/(no_of_sub+3));

rx12=rx1';

rx13 = rx12(:,[(4:(no_of_sub+3))]);

rx14=rx13';

fft_data_received =fft(rx14);

channel_response=fft([gain1;gain2;gain3;gain4],no_of_sub);

data_equilized=fft_data_received.*conj(channel_response);

ku=no_of_user;

recdata11=(data_equilized'*(code{ku})')';

recdata12=real(recdata11)>0;

mess1=deintrlv(uint8(recdata12),ele{ku})

out_data= decode(double(mess1),n,k,'cyclic'); % Code will be a binary column.

errors_user1= size(find([data{ku}- out_data]),2);

bit_error_rate1(i)= errors_user1/N;

end

%% sinc

no_of_user=70;

no_of_sub =8;

N=10^3;

Nk=N;

fs = Nk/2;

t = linspace(-5,5,Nk);

pulse_sin =sinc(t)>0.05;

pulse_value1=pulse_sin(1:Nk);

%%

length_mess=no_of_user*N;

walsh1=hadamard(no_of_sub);

walsh=REEDMULER(walsh1);

kux=1;

for ku=1:no_of_user

code{ku}=walsh(kux,:);

kux=kux+1;

if(kux==no_of_sub)

kux=1;

end

end

n = 6; k = 4; % Set codeword length and message length % for a [6,4] code.

%%

original_message=randint(1,length_mess,2);

locx=1;

locy=N;

for ku=1:no_of_user

data{ku}= original_message(locx:locy);

msg=double(xor(data{ku},pulse_value));

mess= encode((msg),n,k,'cyclic'); % Code will be a binary column.

len=length(mess);

ele{ku}=randperm(len);

intr_lve{ku}=intrlv(mess,ele{ku})

datamod = (2*intr_lve{ku}-1);

user_data_mod{ku}=datamod';

locx=locy+1

locy=locx+(N-1)

end

%%

for ku=1:no_of_user

data_user11=user_data_mod{ku};

spdata1_user1=data_user11*(code{ku});

spdata12=(spdata1_user1)';

ifftdata_user1=ifft(spdata12);

ifftdata12=ifftdata_user1';

y1=[ifftdata12(:,[(no_of_sub-2):no_of_sub]) ifftdata12];

transdata1=y1';

tx_user=transdata1;

sp_data{ku}=tx_user;

end

%%

tx_data_final=zeros(size(sp_data{1}));

for ku=1:no_of_user

tx_data_final=tx_data_final+sp_data{ku};

end

%%

for ku=2:no_of_user

N1=N*(n/k);

Taps=4;

p1=0.5/2.3;

p2=0.9/2.3;

p3=0.7/2.3;

p4=0.2/2.3;

gain1=sqrt(p1/2)*[randn(1,N1) + j*randn(1,N1)];

gain2=sqrt(p2/2)*[randn(1,N1) + j*randn(1,N1)];

gain3=sqrt(p3/2)*[randn(1,N1) + j*randn(1,N1)];

gain4=sqrt(p4/2)*[randn(1,N1) + j*randn(1,N1)];

tx_data_final=sp_data{ku-1}+sp_data{ku};

x11=tx_data_final(:);

x12=reshape(x11,1,length(x11));

i=1:length(x12);

%%

delay1=1;

for i=delay1+1:length(x12)

x13(i)=tx_data_final(i-delay1);

end

delay2=2;

for i=delay2+1:length(x12)

x14(i)=tx_data_final(i-delay2);

end

delay3=3;

for i=delay3+1:length(x12)

x15(i)=tx_data_final(i-delay3);

end

x1=reshape(x13,(no_of_sub+3),length(x13)/(no_of_sub+3));

x2=reshape(x14,(no_of_sub+3),length(x14)/(no_of_sub+3));

x3=reshape(x15,(no_of_sub+3),length(x15)/(no_of_sub+3));

ch1=repmat(gain1,(no_of_sub+3),1);

ch2=repmat(gain2,(no_of_sub+3),1);

ch3=repmat(gain3,(no_of_sub+3),1);

ch4=repmat(gain4,(no_of_sub+3),1);

data_channel=(tx_data_final).*ch1+x1.*ch2+x2.*ch3+x3.*ch4;

data_noise1=data_channel(:);

data_noise2=reshape(data_noise1,1,length(data_noise1));

end

%%

noise = 1/sqrt(2)*[randn(1,length(data_noise2)) + j*randn(1,length(data_noise2))];

snr = [0:1:18];

for i = 1:length(snr)

y = data_noise2 + (sqrt(1)*10^(-(snr(i))/10))*noise; %Addition of Noise

data_received =y;

rx1=reshape(data_received,(no_of_sub+3),length(data_received)/(no_of_sub+3));

rx12=rx1';

rx13 = rx12(:,[(4:(no_of_sub+3))]);

rx14=rx13';

fft_data_received =fft(rx14);

channel_response=fft([gain1;gain2;gain3;gain4],no_of_sub);

data_equilized=fft_data_received.*conj(channel_response);

ku=no_of_user;

recdata11=(data_equilized'*(code{ku})')';

recdata12=real(recdata11)>0;

mess1=deintrlv(uint8(recdata12),ele{ku})

out_data= decode(double(mess1),n,k,'cyclic'); % Code will be a binary column.

errors_user1= size(find([data{ku}- out_data]),2);

bit_error_rate2(i)= errors_user1/(N);

end

figure,semilogy(snr,bit_error_rate1,'r*:',snr,bit_error_rate2,'ks-','linewidth',2);

title('performance');

xlabel('SNR value');

ylabel('bit error rate');

grid on;

clear all;

close all;

clc;

%% 70

no_of_user=70;

no_of_sub =8;

N=10^3;

%%

length_mess=no_of_user*N;

walsh1=hadamard(no_of_sub);

walsh=REEDMULER(walsh1);

kux=1;

for ku=1:no_of_user

code{ku}=walsh(kux,:);

kux=kux+1;

if(kux==no_of_sub)

kux=1;

end

end

n = 6; k = 4; % Set codeword length and message length % for a [6,4] code.

%%

original_message=randint(1,length_mess,2);

locx=1;

locy=N;

for ku=1:no_of_user

data{ku}= original_message(locx:locy);

msg=data{ku};

mess= encode(msg,n,k,'cyclic'); % Code will be a binary column.

len=length(mess);

ele{ku}=randperm(len);

intr_lve{ku}=intrlv(mess,ele{ku})

datamod = 2*intr_lve{ku}-1;

user_data_mod{ku}=datamod';

locx=locy+1

locy=locx+(N-1)

end

%%

for ku=1:no_of_user

data_user11=user_data_mod{ku};

spdata1_user1=data_user11*(code{ku});

spdata12=(spdata1_user1)';

ifftdata_user1=ifft(spdata12);

ifftdata12=ifftdata_user1';

y1=[ifftdata12(:,[(no_of_sub-2):no_of_sub]) ifftdata12];

transdata1=y1';

tx_user=transdata1;

sp_data{ku}=tx_user;

end

%%

tx_data_final=zeros(size(sp_data{1}));

for ku=1:no_of_user

tx_data_final=tx_data_final+sp_data{ku};

end

%%

for ku=2:no_of_user

N1=N*(n/k);

Taps=4;

p1=0.5/2.3;

p2=0.9/2.3;

p3=0.7/2.3;

p4=0.2/2.3;

gain1=sqrt(p1/2)*[randn(1,N1) + j*randn(1,N1)];

gain2=sqrt(p2/2)*[randn(1,N1) + j*randn(1,N1)];

gain3=sqrt(p3/2)*[randn(1,N1) + j*randn(1,N1)];

gain4=sqrt(p4/2)*[randn(1,N1) + j*randn(1,N1)];

tx_data_final=sp_data{ku-1}+sp_data{ku};

x11=tx_data_final(:);

x12=reshape(x11,1,length(x11));

i=1:length(x12);

%%

delay1=1;

for i=delay1+1:length(x12)

x13(i)=tx_data_final(i-delay1);

end

delay2=2;

for i=delay2+1:length(x12)

x14(i)=tx_data_final(i-delay2);

end

delay3=3;

for i=delay3+1:length(x12)

x15(i)=tx_data_final(i-delay3);

end

x1=reshape(x13,(no_of_sub+3),length(x13)/(no_of_sub+3));

x2=reshape(x14,(no_of_sub+3),length(x14)/(no_of_sub+3));

x3=reshape(x15,(no_of_sub+3),length(x15)/(no_of_sub+3));

ch1=repmat(gain1,(no_of_sub+3),1);

ch2=repmat(gain2,(no_of_sub+3),1);

ch3=repmat(gain3,(no_of_sub+3),1);

ch4=repmat(gain4,(no_of_sub+3),1);

data_channel=(tx_data_final).*ch1+x1.*ch2+x2.*ch3+x3.*ch4;

data_noise1=data_channel(:);

data_noise2=reshape(data_noise1,1,length(data_noise1));

end

%%

noise = 1/sqrt(2)*[randn(1,length(data_noise2)) + j*randn(1,length(data_noise2))];

snr = [0:2:8];

for i = 1:length(snr)

y = data_noise2 + (sqrt(1)*10^(-snr(i)/20))*noise; %Addition of Noise

data_received =y;

rx1=reshape(data_received,(no_of_sub+3),length(data_received)/(no_of_sub+3));

rx12=rx1';

rx13 = rx12(:,[(4:(no_of_sub+3))]);

rx14=rx13';

fft_data_received =fft(rx14);

channel_response=fft([gain1;gain2;gain3;gain4],no_of_sub);

data_equilized=fft_data_received.*conj(channel_response);

ku=no_of_user;

recdata11=(data_equilized'*(code{ku})')';

recdata12=real(recdata11)>0;

mess1=deintrlv(uint8(recdata12),ele{ku})

out_data= decode(double(mess1),n,k,'cyclic'); % Code will be a binary column.

errors_user1= size(find([data{ku}- out_data]),2);

bit_error_rate1(i)= errors_user1/N;

end

%%

%% 70

no_of_user=70;

no_of_sub =8;

N=10^3;

%%

length_mess=no_of_user*N;

walsh1=hadamard(no_of_sub);

walsh=REEDMULER(walsh1);

kux=1;

for ku=1:no_of_user

code{ku}=walsh(kux,:);

kux=kux+1;

if(kux==no_of_sub)

kux=1;

end

end

n = 6; k = 4; % Set codeword length and message length % for a [6,4] code.

%%

original_message=randint(1,length_mess,2);

locx=1;

locy=N;

for ku=1:no_of_user

data{ku}= original_message(locx:locy);

msg=data{ku};

mess= encode(msg,n,k,'cyclic'); % Code will be a binary column.

len=length(mess);

ele{ku}=randperm(len);

intr_lve{ku}=intrlv(mess,ele{ku})

datamod = 2*intr_lve{ku}-1;

user_data_mod{ku}=datamod';

locx=locy+1

locy=locx+(N-1)

end

%%

for ku=1:no_of_user

data_user11=user_data_mod{ku};

spdata1_user1=data_user11*(code{ku});

spdata12=(spdata1_user1)';

ifftdata_user1=ifft(spdata12);

ifftdata12=ifftdata_user1';

y1=[ifftdata12(:,[(no_of_sub-2):no_of_sub]) ifftdata12];

transdata1=y1';

tx_user=transdata1;

sp_data{ku}=tx_user;

end

%%

tx_data_final=zeros(size(sp_data{1}));

for ku=1:no_of_user

tx_data_final=tx_data_final+sp_data{ku};

end

%%

for ku=2:no_of_user

N1=N*(n/k);

Taps=4;

p1=0.5/1.6;

p2=0.9/1.5;

p3=0.7/1.3;

p4=0.2/0.4;

gain1=sqrt(p1/2)*[randn(1,N1) + j*randn(1,N1)];

gain2=sqrt(p2/2)*[randn(1,N1) + j*randn(1,N1)];

gain3=sqrt(p3/2)*[randn(1,N1) + j*randn(1,N1)];

gain4=sqrt(p4/2)*[randn(1,N1) + j*randn(1,N1)];

tx_data_final=sp_data{ku-1}+sp_data{ku};

x11=tx_data_final(:);

x12=reshape(x11,1,length(x11));

i=1:length(x12);

%%

delay1=1;

for i=delay1+1:length(x12)

x13(i)=tx_data_final(i-delay1);

end

delay2=2;

for i=delay2+1:length(x12)

x14(i)=tx_data_final(i-delay2);

end

delay3=3;

for i=delay3+1:length(x12)

x15(i)=tx_data_final(i-delay3);

end

x1=reshape(x13,(no_of_sub+3),length(x13)/(no_of_sub+3));

x2=reshape(x14,(no_of_sub+3),length(x14)/(no_of_sub+3));

x3=reshape(x15,(no_of_sub+3),length(x15)/(no_of_sub+3));

ch1=repmat(gain1,(no_of_sub+3),1);

ch2=repmat(gain2,(no_of_sub+3),1);

ch3=repmat(gain3,(no_of_sub+3),1);

ch4=repmat(gain4,(no_of_sub+3),1);

data_channel=(tx_data_final).*ch1+x1.*ch2+x2.*ch3+x3.*ch4;

data_noise1=data_channel(:);

data_noise2=reshape(data_noise1,1,length(data_noise1));

end

%%

noise = 1/sqrt(2)*[randn(1,length(data_noise2)) + j*randn(1,length(data_noise2))];

snr = [0:2:8];

for i = 1:length(snr)

y = data_noise2 + (sqrt(1)*10^(-snr(i)/20))*noise; %Addition of Noise

data_received =y;

rx1=reshape(data_received,(no_of_sub+3),length(data_received)/(no_of_sub+3));

rx12=rx1';

rx13 = rx12(:,[(4:(no_of_sub+3))]);

rx14=rx13';

fft_data_received =fft(rx14);

channel_response=fft([gain1;gain2;gain3;gain4],no_of_sub);

data_equilized=fft_data_received.*conj(channel_response);

ku=no_of_user;

recdata11=(data_equilized'*(code{ku})')';

recdata12=real(recdata11)>0;

mess1=deintrlv(uint8(recdata12),ele{ku})

out_data= decode(double(mess1),n,k,'cyclic'); % Code will be a binary column.

errors_user1= size(find([data{ku}- out_data]),2);

bit_error_rate2(i)= errors_user1/N;

end

figure,semilogy(snr,bit_error_rate1,'k<-.',snr,bit_error_rate2,'g>-','linewidth',2);

legend('ucorrelation ','correlation');

title('performance');

xlabel('SNR value');

ylabel('bit error rate');

grid on;

clear all

clc

close all

no_of_user=70;

sub_ch=[4 8 16 32];

N=10^3;

for ksub=1:length(sub_ch)

no_of_sub =sub_ch(ksub);

%%

length_mess=no_of_user*N;

walsh1=hadamard(no_of_sub);

walsh=REEDMULER(walsh1);

kux=1;

for ku=1:no_of_user

code{ku}=walsh(kux,:);

kux=kux+1;

if(kux==no_of_sub)

kux=1;

end

end

n = 6; k = 4; % Set codeword length and message length % for a [6,4] code.

%%

original_message=randint(1,length_mess,2);

locx=1;

locy=N;

for ku=1:no_of_user

data{ku}= original_message(locx:locy);

msg=data{ku};

mess= encode(msg,n,k,'cyclic'); % Code will be a binary column.

len=length(mess);

ele{ku}=randperm(len);

intr_lve{ku}=intrlv(mess,ele{ku});

datamod = 2*intr_lve{ku}-1;

user_data_mod{ku}=datamod';

locx=locy+1;

locy=locx+(N-1);

end

%%

for ku=1:no_of_user

data_user11=user_data_mod{ku};

spdata1_user1=data_user11*(code{ku});

spdata12=(spdata1_user1)';

ifftdata_user1=ifft(spdata12);

ifftdata12=ifftdata_user1';

y1=[ifftdata12(:,[(no_of_sub-2):no_of_sub]) ifftdata12];

transdata1=y1';

tx_user=transdata1;

sp_data{ku}=tx_user;

end

%%

tx_data_final=zeros(size(sp_data{1}));

for ku=1:no_of_user

tx_data_final=tx_data_final+sp_data{ku};

end

%%

for ku=2:no_of_user

N1=N*(n/k);

Taps=4;

p1=0.5/2.3;

p2=0.9/2.3;

p3=0.7/2.3;

p4=0.2/2.3;

gain1=sqrt(p1/2)*[randn(1,N1) + j*randn(1,N1)];

gain2=sqrt(p2/2)*[randn(1,N1) + j*randn(1,N1)];

gain3=sqrt(p3/2)*[randn(1,N1) + j*randn(1,N1)];

gain4=sqrt(p4/2)*[randn(1,N1) + j*randn(1,N1)];

tx_data_final=sp_data{ku-1}+sp_data{ku};

x11=tx_data_final(:);

x12=reshape(x11,1,length(x11));

i=1:length(x12);

%%

delay1=4;

for i=delay1+1:length(x12)

x13(i)=tx_data_final(i-delay1);

end

delay2=4;

for i=delay2+1:length(x12)

x14(i)=tx_data_final(i-delay2);

end

delay3=4;

for i=delay3+1:length(x12)

x15(i)=tx_data_final(i-delay3);

end

x1=reshape(x13,(no_of_sub+3),length(x13)/(no_of_sub+3));

x2=reshape(x14,(no_of_sub+3),length(x14)/(no_of_sub+3));

x3=reshape(x15,(no_of_sub+3),length(x15)/(no_of_sub+3));

ch1=repmat(gain1,(no_of_sub+3),1);

ch2=repmat(gain2,(no_of_sub+3),1);

ch3=repmat(gain3,(no_of_sub+3),1);

ch4=repmat(gain4,(no_of_sub+3),1);

data_channel=(tx_data_final).*ch1+x1.*ch2+x2.*ch3+x3.*ch4;

data_noise1=data_channel(:);

data_noise2=reshape(data_noise1,1,length(data_noise1));

end

%%

noise = 1/sqrt(2)*[randn(1,length(data_noise2)) + j*randn(1,length(data_noise2))];

snr = [10];

for i = 1:length(snr)

y = data_noise2 + (sqrt(1)*10^(-snr(i)/20))*noise; %Addition of Noise

data_received =y;

rx1=reshape(data_received,(no_of_sub+3),length(data_received)/(no_of_sub+3));

rx12=rx1';

rx13 = rx12(:,[(4:(no_of_sub+3))]);

rx14=rx13';

fft_data_received =fft(rx14);

channel_response=fft([gain1;gain2;gain3;gain4],no_of_sub);

data_equilized=fft_data_received.*conj(channel_response);

ku=no_of_user;

recdata11=(data_equilized'*(code{ku})')';

recdata12=real(recdata11)>0;

mess1=deintrlv(uint8(recdata12),ele{ku});

out_data= decode(double(mess1),n,k,'cyclic'); % Code will be a binary column.

errors_user1= size(find([data{ku}- out_data]),2);

bit_errorx1= errors_user1/N;

end

bit_error_rate1(ksub)=bit_errorx1;

end

clear x13 x14 x15

%%

no_of_user=70;

sub_ch=[4 8 16 32];

N=10^3;

for ksub=1:length(sub_ch)

no_of_sub =sub_ch(ksub);

%%

length_mess=no_of_user*N;

walsh1=hadamard(no_of_sub);

walsh=REEDMULER(walsh1);

kux=1;

for ku=1:no_of_user

code{ku}=walsh(kux,:);

kux=kux+1;

if(kux==no_of_sub)

kux=1;

end

end

n = 6; k = 4; % Set codeword length and message length % for a [6,4] code.

%%

original_message=randint(1,length_mess,2);

locx=1;

locy=N;

for ku=1:no_of_user

data{ku}= original_message(locx:locy);

msg=data{ku};

mess= encode(msg,n,k,'cyclic'); % Code will be a binary column.

len=length(mess);

ele{ku}=randperm(len);

intr_lve{ku}=intrlv(mess,ele{ku});

datamod = 2*intr_lve{ku}-1;

user_data_mod{ku}=datamod';

locx=locy+1;

locy=locx+(N-1);

end

%%

for ku=1:no_of_user

data_user11=user_data_mod{ku};

spdata1_user1=data_user11*(code{ku});

spdata12=(spdata1_user1)';

ifftdata_user1=ifft(spdata12);

ifftdata12=ifftdata_user1';

y1=[ifftdata12(:,[(no_of_sub-2):no_of_sub]) ifftdata12];

transdata1=y1';

tx_user=transdata1;

sp_data{ku}=tx_user;

end

%%

tx_data_final=zeros(size(sp_data{1}));

for ku=1:no_of_user

tx_data_final=tx_data_final+sp_data{ku};

end

%%

for ku=2:no_of_user

N1=N*(n/k);

Taps=4;

p1=0.5/2.3;

p2=0.9/2.3;

p3=0.7/2.3;

p4=0.2/2.3;

gain1=sqrt(p1/2)*[randn(1,N1) + j*randn(1,N1)];

gain2=sqrt(p2/2)*[randn(1,N1) + j*randn(1,N1)];

gain3=sqrt(p3/2)*[randn(1,N1) + j*randn(1,N1)];

gain4=sqrt(p4/2)*[randn(1,N1) + j*randn(1,N1)];

tx_data_final=sp_data{ku-1}+sp_data{ku};

x11=tx_data_final(:);

x12=reshape(x11,1,length(x11));

i=1:length(x12);

%%

delay1=2;

for i=delay1+1:length(x12)

x13(i)=tx_data_final(i-delay1);

end

delay2=2;

for i=delay2+1:length(x12)

x14(i)=tx_data_final(i-delay2);

end

delay3=2;

for i=delay3+1:length(x12)

x15(i)=tx_data_final(i-delay3);

end

x1=reshape(x13,(no_of_sub+3),length(x13)/(no_of_sub+3));

x2=reshape(x14,(no_of_sub+3),length(x14)/(no_of_sub+3));

x3=reshape(x15,(no_of_sub+3),length(x15)/(no_of_sub+3));

ch1=repmat(gain1,(no_of_sub+3),1);

ch2=repmat(gain2,(no_of_sub+3),1);

ch3=repmat(gain3,(no_of_sub+3),1);

ch4=repmat(gain4,(no_of_sub+3),1);

data_channel=(tx_data_final).*ch1+x1.*ch2+x2.*ch3+x3.*ch4;

data_noise1=data_channel(:);

data_noise2=reshape(data_noise1,1,length(data_noise1));

end

%%

noise = 1/sqrt(2)*[randn(1,length(data_noise2)) + j*randn(1,length(data_noise2))];

snr = [10];

for i = 1:length(snr)

y = data_noise2 + (sqrt(1)*10^(-snr(i)/15))*noise; %Addition of Noise

data_received =y;

rx1=reshape(data_received,(no_of_sub+3),length(data_received)/(no_of_sub+3));

rx12=rx1';

rx13 = rx12(:,[(4:(no_of_sub+3))]);

rx14=rx13';

fft_data_received =fft(rx14);

channel_response=fft([gain1;gain2;gain3;gain4],no_of_sub);

data_equilized=fft_data_received.*conj(channel_response);

ku=no_of_user;

recdata11=(data_equilized'*(code{ku})')';

recdata12=real(recdata11)>0;

mess1=deintrlv(uint8(recdata12),ele{ku});

out_data= decode(double(mess1),n,k,'cyclic'); % Code will be a binary column.

errors_user1= size(find([data{ku}- out_data]),2);

bit_errorx1= errors_user1/N;

end

bit_error_rate2(ksub)=bit_errorx1;

end

clear x13 x14 x15

%%

no_of_user=70;

sub_ch=[4 8 16 32];

N=10^3;

for ksub=1:length(sub_ch)

no_of_sub =sub_ch(ksub);

%%

length_mess=no_of_user*N;

walsh1=hadamard(no_of_sub);

walsh=REEDMULER(walsh1);

kux=1;

for ku=1:no_of_user

code{ku}=walsh(kux,:);

kux=kux+1;

if(kux==no_of_sub)

kux=1;

end

end

n = 6; k = 4; % Set codeword length and message length % for a [6,4] code.

%%

original_message=randint(1,length_mess,2);

locx=1;

locy=N;

for ku=1:no_of_user

data{ku}= original_message(locx:locy);

msg=data{ku};

mess= encode(msg,n,k,'cyclic'); % Code will be a binary column.

len=length(mess);

ele{ku}=randperm(len);

intr_lve{ku}=intrlv(mess,ele{ku});

datamod = 2*intr_lve{ku}-1;

user_data_mod{ku}=datamod';

locx=locy+1;

locy=locx+(N-1);

end

%%

for ku=1:no_of_user

data_user11=user_data_mod{ku};

spdata1_user1=data_user11*(code{ku});

spdata12=(spdata1_user1)';

ifftdata_user1=ifft(spdata12);

ifftdata12=ifftdata_user1';

y1=[ifftdata12(:,[(no_of_sub-2):no_of_sub]) ifftdata12];

transdata1=y1';

tx_user=transdata1;

sp_data{ku}=tx_user;

end

%%

tx_data_final=zeros(size(sp_data{1}));

for ku=1:no_of_user

tx_data_final=tx_data_final+sp_data{ku};

end

%%

for ku=2:no_of_user

N1=N*(n/k);

Taps=4;

p1=0.5/2.3;

p2=0.9/2.3;

p3=0.7/2.3;

p4=0.2/2.3;

gain1=sqrt(p1/2)*[randn(1,N1) + j*randn(1,N1)];

gain2=sqrt(p2/2)*[randn(1,N1) + j*randn(1,N1)];

gain3=sqrt(p3/2)*[randn(1,N1) + j*randn(1,N1)];

gain4=sqrt(p4/2)*[randn(1,N1) + j*randn(1,N1)];

tx_data_final=sp_data{ku-1}+sp_data{ku};

x11=tx_data_final(:);

x12=reshape(x11,1,length(x11));

i=1:length(x12);

%%

delay1=1;

for i=delay1+1:length(x12)

x13(i)=tx_data_final(i-delay1);

end

delay2=1;

for i=delay2+1:length(x12)

x14(i)=tx_data_final(i-delay2);

end

delay3=1;

for i=delay3+1:length(x12)

x15(i)=tx_data_final(i-delay3);

end

x1=reshape(x13,(no_of_sub+3),length(x13)/(no_of_sub+3));

x2=reshape(x14,(no_of_sub+3),length(x14)/(no_of_sub+3));

x3=reshape(x15,(no_of_sub+3),length(x15)/(no_of_sub+3));

ch1=repmat(gain1,(no_of_sub+3),1);

ch2=repmat(gain2,(no_of_sub+3),1);

ch3=repmat(gain3,(no_of_sub+3),1);

ch4=repmat(gain4,(no_of_sub+3),1);

data_channel=(tx_data_final).*ch1+x1.*ch2+x2.*ch3+x3.*ch4;

data_noise1=data_channel(:);

data_noise2=reshape(data_noise1,1,length(data_noise1));

end

%%

noise = 1/sqrt(2)*[randn(1,length(data_noise2)) + j*randn(1,length(data_noise2))];

snr = [10];

for i = 1:length(snr)

y = data_noise2 + (sqrt(1)*10^(-snr(i)/10))*noise; %Addition of Noise

data_received =y;

rx1=reshape(data_received,(no_of_sub+3),length(data_received)/(no_of_sub+3));

rx12=rx1';

rx13 = rx12(:,[(4:(no_of_sub+3))]);

rx14=rx13';

fft_data_received =fft(rx14);

channel_response=fft([gain1;gain2;gain3;gain4],no_of_sub);

data_equilized=fft_data_received.*conj(channel_response);

ku=no_of_user;

recdata11=(data_equilized'*(code{ku})')';

recdata12=real(recdata11)>0;

mess1=deintrlv(uint8(recdata12),ele{ku});

out_data= decode(double(mess1),n,k,'cyclic'); % Code will be a binary column.

errors_user1= size(find([data{ku}- out_data]),2);

bit_errorx1= errors_user1/N;

end

bit_error_rate3(ksub)=bit_errorx1;

end

%% plot

figure,semilogy(sub_ch,bit_error_rate1,'k<-.',sub_ch,bit_error_rate2,'g>-',sub_ch,bit_error_rate3,'rs:','linewidth',2);

axis([4 32 10^-3 10^0]);

legend('delay case1 ','delay case2','delay case3');

title('performance');

xlabel('SNR value');

ylabel('bit error rate');

grid on;

clear all;

close all;

clc;

%%

no_of_user=50;

sub_ch=[4 8 16];

N=10^3;

for ksub=1:length(sub_ch)

no_of_sub =sub_ch(ksub);

%%

length_mess=no_of_user*N;

walsh1=hadamard(no_of_sub);

walsh=REEDMULER(walsh1);

kux=1;

for ku=1:no_of_user

code{ku}=walsh(kux,:);

kux=kux+1;

if(kux==no_of_sub)

kux=1;

end

end

n = 6; k = 4; % Set codeword length and message length % for a [6,4] code.

%%

original_message=randint(1,length_mess,2);

locx=1;

locy=N;

for ku=1:no_of_user

data{ku}= original_message(locx:locy);

datamod = 2*data{ku}-1;

user_data_mod{ku}=datamod';

locx=locy+1

locy=locx+(N-1)

end

%%

for ku=1:no_of_user

data_user11=user_data_mod{ku};

spdata1_user1=data_user11*(code{ku});

spdata12=(spdata1_user1)';

ifftdata_user1=ifft(spdata12);

ifftdata12=ifftdata_user1';

y1=[ifftdata12(:,[(no_of_sub-2):no_of_sub]) ifftdata12];

transdata1=y1';

tx_user=transdata1;

sp_data{ku}=tx_user;

end

%%

tx_data_final=zeros(size(sp_data{1}));

for ku=1:no_of_user

tx_data_final=tx_data_final+sp_data{ku};

end

%%

for ku=2:no_of_user

N1=N;

Taps=4;

p1=0.5/2.3;

p2=0.9/2.3;

p3=0.7/2.3;

p4=0.2/2.3;

gain1=sqrt(p1/2)*[randn(1,N1) + j*randn(1,N1)];

gain2=sqrt(p2/2)*[randn(1,N1) + j*randn(1,N1)];

gain3=sqrt(p3/2)*[randn(1,N1) + j*randn(1,N1)];

gain4=sqrt(p4/2)*[randn(1,N1) + j*randn(1,N1)];

tx_data_final=sp_data{ku-1}+sp_data{ku};

x11=tx_data_final(:);

x12=reshape(x11,1,length(x11));

i=1:length(x12);

%%

delay1=1;

for i=delay1+1:length(x12)

x13(i)=tx_data_final(i-delay1);

end

delay2=2;

for i=delay2+1:length(x12)

x14(i)=tx_data_final(i-delay2);

end

delay3=3;

for i=delay3+1:length(x12)

x15(i)=tx_data_final(i-delay3);

end

x1=reshape(x13,(no_of_sub+3),length(x13)/(no_of_sub+3));

x2=reshape(x14,(no_of_sub+3),length(x14)/(no_of_sub+3));

x3=reshape(x15,(no_of_sub+3),length(x15)/(no_of_sub+3));

ch1=repmat(gain1,(no_of_sub+3),1);

ch2=repmat(gain2,(no_of_sub+3),1);

ch3=repmat(gain3,(no_of_sub+3),1);

ch4=repmat(gain4,(no_of_sub+3),1);

data_channel=(tx_data_final).*ch1+x1.*ch2+x2.*ch3+x3.*ch4;

data_noise1=data_channel(:);

data_noise2=reshape(data_noise1,1,length(data_noise1));

end

%%

noise = 1/sqrt(2)*[randn(1,length(data_noise2)) + j*randn(1,length(data_noise2))];

snr = [0];

for i = 1:length(snr)

y = data_noise2 + (sqrt(1)*10^(-snr(i)/20))*noise; %Addition of Noise

data_received =y;

rx1=reshape(data_received,(no_of_sub+3),length(data_received)/(no_of_sub+3));

rx12=rx1';

rx13 = rx12(:,[(4:(no_of_sub+3))]);

rx14=rx13';

fft_data_received =fft(rx14);

channel_response=fft([gain1;gain2;gain3;gain4],no_of_sub);

data_equilized=fft_data_received.*conj(channel_response);

ku=no_of_user;

recdata11=(data_equilized'*(code{ku})')';

recdata12=real(recdata11)>0;

out_data=recdata12;

errors_user1= size(find([data{ku}- out_data]),2);

bit_errorx(i)= errors_user1/N;

end

bit_error_rate(ksub)=bit_errorx;

end

%%

clear x13 x14 x15

no_of_user=50;

sub_ch=[4 8 16];

N=10^3;

for ksub=1:length(sub_ch)

no_of_sub =sub_ch(ksub)

%%

length_mess=no_of_user*N;

walsh1=hadamard(no_of_sub);

walsh=REEDMULER(walsh1);

kux=1;

for ku=1:no_of_user

code{ku}=walsh(kux,:);

kux=kux+1;

if(kux==no_of_sub)

kux=1;

end

end

n = 6; k = 4; % Set codeword length and message length % for a [6,4] code.

%%

original_message=randint(1,length_mess,2);

locx=1;

locy=N;

for ku=1:no_of_user

data{ku}= original_message(locx:locy);

msg=data{ku};

mess= encode(msg,n,k,'cyclic'); % Code will be a binary column.

len=length(mess);

ele{ku}=randperm(len);

intr_lve{ku}=intrlv(mess,ele{ku});

datamod = 2*intr_lve{ku}-1;

user_data_mod{ku}=datamod';

locx=locy+1;

locy=locx+(N-1);

end

%%

for ku=1:no_of_user

data_user11=user_data_mod{ku};

spdata1_user1=data_user11*(code{ku});

spdata12=(spdata1_user1)';

ifftdata_user1=ifft(spdata12);

ifftdata12=ifftdata_user1';

y1=[ifftdata12(:,[(no_of_sub-2):no_of_sub]) ifftdata12];

transdata1=y1';

tx_user=transdata1;

sp_data{ku}=tx_user;

end

%%

tx_data_final=zeros(size(sp_data{1}));

for ku=1:no_of_user

tx_data_final=tx_data_final+sp_data{ku};

end

%%

for ku=2:no_of_user

N1=N*(n/k);

Taps=4;

p1=0.5/2.3;

p2=0.9/2.3;

p3=0.7/2.3;

p4=0.2/2.3;

gain1=sqrt(p1/2)*[randn(1,N1) + j*randn(1,N1)];

gain2=sqrt(p2/2)*[randn(1,N1) + j*randn(1,N1)];

gain3=sqrt(p3/2)*[randn(1,N1) + j*randn(1,N1)];

gain4=sqrt(p4/2)*[randn(1,N1) + j*randn(1,N1)];

tx_data_final=sp_data{ku-1}+sp_data{ku};

x11=tx_data_final(:);

x12=reshape(x11,1,length(x11));

i=1:length(x12);

%%

delay1=1;

for i=delay1+1:length(x12)

x13(i)=tx_data_final(i-delay1);

end

delay2=2;

for i=delay2+1:length(x12)

x14(i)=tx_data_final(i-delay2);

end

delay3=3;

for i=delay3+1:length(x12)

x15(i)=tx_data_final(i-delay3);

end

x1=reshape(x13,(no_of_sub+3),length(x13)/(no_of_sub+3));

x2=reshape(x14,(no_of_sub+3),length(x14)/(no_of_sub+3));

x3=reshape(x15,(no_of_sub+3),length(x15)/(no_of_sub+3));

ch1=repmat(gain1,(no_of_sub+3),1);

ch2=repmat(gain2,(no_of_sub+3),1);

ch3=repmat(gain3,(no_of_sub+3),1);

ch4=repmat(gain4,(no_of_sub+3),1);

data_channel=(tx_data_final).*ch1+x1.*ch2+x2.*ch3+x3.*ch4;

data_noise1=data_channel(:);

data_noise2=reshape(data_noise1,1,length(data_noise1));

end

%%

noise = 1/sqrt(2)*[randn(1,length(data_noise2)) + j*randn(1,length(data_noise2))];

snr = [0];

for i = 1:length(snr)

y = data_noise2 + (sqrt(1)*10^(-snr(i)/20))*noise; %Addition of Noise

data_received =y;

rx1=reshape(data_received,(no_of_sub+3),length(data_received)/(no_of_sub+3));

rx12=rx1';

rx13 = rx12(:,[(4:(no_of_sub+3))]);

rx14=rx13';

fft_data_received =fft(rx14);

channel_response=fft([gain1;gain2;gain3;gain4],no_of_sub);

data_equilized=fft_data_received.*conj(channel_response);

ku=no_of_user;

recdata11=(data_equilized'*(code{ku})')';

recdata12=real(recdata11)>0;

mess1=deintrlv(uint8(recdata12),ele{ku});

out_data= decode(double(mess1),n,k,'cyclic'); % Code will be a binary column.

errors_user1= size(find([data{ku}- out_data]),2);

bit_errorx1= errors_user1/N;

end

bit_error_rate1(ksub)=bit_errorx1;

end

figure,semilogy(sub_ch,bit_error_rate,'k<-.',sub_ch,bit_error_rate1,'g>-','linewidth',2);

axis([4 16 10^-2 10^0]);

legend('without inter ','with inter');

title('performance');

xlabel('SNR value');

ylabel('bit error rate');

grid on;

clear all;

close all;

clc;

%%

no_of_user=50;

sub_ch=[4 8 16];

N=10^3;

for ksub=1:length(sub_ch)

no_of_sub =sub_ch(ksub);

length_mess=no_of_user*N;

walsh1=hadamard(no_of_sub);

walsh=REEDMULER(walsh1);

kux=1;

for ku=1:no_of_user

code{ku}=walsh(kux,:);

kux=kux+1;

if(kux==no_of_sub)

kux=1;

end

end

n = 6; k = 4; % Set codeword length and message length % for a [6,4] code.

%%

original_message=randint(1,length_mess,2);

locx=1;

locy=N;

for ku=1:no_of_user

data{ku}= original_message(locx:locy);

datamod = 2*data{ku}-1;

user_data_mod{ku}=datamod';

locx=locy+1

locy=locx+(N-1)

end

%%

for ku=1:no_of_user

data_user11=user_data_mod{ku};

spdata1_user1=data_user11*(code{ku});

spdata12=(spdata1_user1)';

ifftdata_user1=ifft(spdata12);

ifftdata12=ifftdata_user1';

y1=[ifftdata12(:,[(no_of_sub-2):no_of_sub]) ifftdata12];

transdata1=y1';

tx_user=transdata1;

sp_data{ku}=tx_user;

end

%%

tx_data_final=zeros(size(sp_data{1}));

for ku=1:no_of_user

tx_data_final=tx_data_final+sp_data{ku};

end

%%

for ku=2:no_of_user

N1=N;

Taps=4;

p1=0.5/2.3;

p2=0.9/2.3;

p3=0.7/2.3;

p4=0.2/2.3;

gain1=sqrt(p1/2)*[randn(1,N1) + j*randn(1,N1)];

gain2=sqrt(p2/2)*[randn(1,N1) + j*randn(1,N1)];

gain3=sqrt(p3/2)*[randn(1,N1) + j*randn(1,N1)];

gain4=sqrt(p4/2)*[randn(1,N1) + j*randn(1,N1)];

tx_data_final=sp_data{ku-1}+sp_data{ku};

x11=tx_data_final(:);

x12=reshape(x11,1,length(x11));

i=1:length(x12);

%%

delay1=8;

for i=delay1+1:length(x12)

x13(i)=tx_data_final(i-delay1);

end

delay2=8;

for i=delay2+1:length(x12)

x14(i)=tx_data_final(i-delay2);

end

delay3=8;

for i=delay3+1:length(x12)

x15(i)=tx_data_final(i-delay3);

end

x1=reshape(x13,(no_of_sub+3),length(x13)/(no_of_sub+3));

x2=reshape(x14,(no_of_sub+3),length(x14)/(no_of_sub+3));

x3=reshape(x15,(no_of_sub+3),length(x15)/(no_of_sub+3));

ch1=repmat(gain1,(no_of_sub+3),1);

ch2=repmat(gain2,(no_of_sub+3),1);

ch3=repmat(gain3,(no_of_sub+3),1);

ch4=repmat(gain4,(no_of_sub+3),1);

data_channel=(tx_data_final).*ch1+x1.*ch2+x2.*ch3+x3.*ch4;

data_noise1=data_channel(:);

data_noise2=reshape(data_noise1,1,length(data_noise1));

end

%%

noise = 1/sqrt(2)*[randn(1,length(data_noise2)) + j*randn(1,length(data_noise2))];

snr = [0];

for i = 1:length(snr)

y = data_noise2 + (sqrt(1)*10^(-snr(i)/20))*noise; %Addition of Noise

data_received =y;

rx1=reshape(data_received,(no_of_sub+3),length(data_received)/(no_of_sub+3));

rx12=rx1';

rx13 = rx12(:,[(4:(no_of_sub+3))]);

rx14=rx13';

fft_data_received =fft(rx14);

channel_response=fft([gain1;gain2;gain3;gain4],no_of_sub);

data_equilized=fft_data_received.*conj(channel_response);

ku=no_of_user;

recdata11=(data_equilized'*(code{ku})')';

recdata12=real(recdata11)>0;

out_data=recdata12;

errors_user1= size(find([data{ku}- out_data]),2);

bit_errorx(i)= errors_user1/N;

end

bit_error_rate(ksub)=bit_errorx;

end

%%

clear x13 x14 x15

no_of_user=50;

sub_ch=[4 8 16];

N=10^3;

for ksub=1:length(sub_ch)

no_of_sub =sub_ch(ksub)

%%

length_mess=no_of_user*N;

walsh1=hadamard(no_of_sub);

walsh=REEDMULER(walsh1);

kux=1;

for ku=1:no_of_user

code{ku}=walsh(kux,:);

kux=kux+1;

if(kux==no_of_sub)

kux=1;

end

end

n = 6; k = 4; % Set codeword length and message length % for a [6,4] code.

%%

original_message=randint(1,length_mess,2);

locx=1;

locy=N;

for ku=1:no_of_user

data{ku}= original_message(locx:locy);

msg=data{ku};

mess= encode(msg,n,k,'cyclic'); % Code will be a binary column.

len=length(mess);

ele{ku}=randperm(len);

intr_lve{ku}=intrlv(mess,ele{ku});

datamod = 2*intr_lve{ku}-1;

user_data_mod{ku}=datamod';

locx=locy+1;

locy=locx+(N-1);

end

%%

for ku=1:no_of_user

data_user11=user_data_mod{ku};

spdata1_user1=data_user11*(code{ku});

spdata12=(spdata1_user1)';

ifftdata_user1=ifft(spdata12);

ifftdata12=ifftdata_user1';

y1=[ifftdata12(:,[(no_of_sub-2):no_of_sub]) ifftdata12];

transdata1=y1';

tx_user=transdata1;

sp_data{ku}=tx_user;

end

%%

tx_data_final=zeros(size(sp_data{1}));

for ku=1:no_of_user

tx_data_final=tx_data_final+sp_data{ku};

end

%%

for ku=2:no_of_user

N1=N*(n/k);

Taps=4;

p1=0.5/2.3;

p2=0.9/2.3;

p3=0.7/2.3;

p4=0.2/2.3;

gain1=sqrt(p1/2)*[randn(1,N1) + j*randn(1,N1)];

gain2=sqrt(p2/2)*[randn(1,N1) + j*randn(1,N1)];

gain3=sqrt(p3/2)*[randn(1,N1) + j*randn(1,N1)];

gain4=sqrt(p4/2)*[randn(1,N1) + j*randn(1,N1)];

tx_data_final=sp_data{ku-1}+sp_data{ku};

x11=tx_data_final(:);

x12=reshape(x11,1,length(x11));

i=1:length(x12);

%%

delay1=8;

for i=delay1+1:length(x12)

x13(i)=tx_data_final(i-delay1);

end

delay2=8;

for i=delay2+1:length(x12)

x14(i)=tx_data_final(i-delay2);

end

delay3=8;

for i=delay3+1:length(x12)

x15(i)=tx_data_final(i-delay3);

end

x1=reshape(x13,(no_of_sub+3),length(x13)/(no_of_sub+3));

x2=reshape(x14,(no_of_sub+3),length(x14)/(no_of_sub+3));

x3=reshape(x15,(no_of_sub+3),length(x15)/(no_of_sub+3));

ch1=repmat(gain1,(no_of_sub+3),1);

ch2=repmat(gain2,(no_of_sub+3),1);

ch3=repmat(gain3,(no_of_sub+3),1);

ch4=repmat(gain4,(no_of_sub+3),1);

data_channel=(tx_data_final).*ch1+x1.*ch2+x2.*ch3+x3.*ch4;

data_noise1=data_channel(:);

data_noise2=reshape(data_noise1,1,length(data_noise1));

end

%%

noise = 1/sqrt(20)*[randn(1,length(data_noise2)) + j*randn(1,length(data_noise2))];

snr = [0];

for i = 1:length(snr)

y = data_noise2 + (sqrt(1)*10^(-snr(i)/20))*noise; %Addition of Noise

data_received =y;

rx1=reshape(data_received,(no_of_sub+3),length(data_received)/(no_of_sub+3));

rx12=rx1';

rx13 = rx12(:,[(4:(no_of_sub+3))]);

rx14=rx13';

fft_data_received =fft(rx14);

channel_response=fft([gain1;gain2;gain3;gain4],no_of_sub);

data_equilized=fft_data_received.*conj(channel_response);

ku=no_of_user;

recdata11=(data_equilized'*(code{ku})')';

recdata12=real(recdata11)>0;

mess1=deintrlv(uint8(recdata12),ele{ku});

out_data= decode(double(mess1),n,k,'cyclic'); % Code will be a binary column.

errors_user1= size(find([data{ku}- out_data]),2);

bit_errorx1= errors_user1/N;

end

bit_error_rate1(ksub)=bit_errorx1;

end

figure,semilogy(sub_ch,bit_error_rate,'k<-.',sub_ch,bit_error_rate1,'g>-','linewidth',2);

axis([4 16 10^-1 10^0]);

legend('without inter ','with inter');

title('performance');

xlabel('sub channel');

ylabel('bit error rate');

grid on;

clear all;

close all;

clc;

%%

no_of_user=50;

sub_ch=[4 8 16];

N=10^3;

for ksub=1:length(sub_ch)

no_of_sub =sub_ch(ksub);

%%

length_mess=no_of_user*N;

walsh1=hadamard(no_of_sub);

walsh=REEDMULER(walsh1);

kux=1;

for ku=1:no_of_user

code{ku}=walsh(kux,:);

kux=kux+1;

if(kux==no_of_sub)

kux=1;

end

end

n = 6; k = 4; % Set codeword length and message length % for a [6,4] code.

%%

original_message=randint(1,length_mess,2);

locx=1;

locy=N;

for ku=1:no_of_user

data{ku}= original_message(locx:locy);

datamod = 2*data{ku}-1;

user_data_mod{ku}=datamod';

locx=locy+1

locy=locx+(N-1)

end

%%

for ku=1:no_of_user

data_user11=user_data_mod{ku};

spdata1_user1=data_user11*(code{ku});

spdata12=(spdata1_user1)';

ifftdata_user1=ifft(spdata12);

ifftdata12=ifftdata_user1';

y1=[ifftdata12(:,[(no_of_sub-2):no_of_sub]) ifftdata12];

transdata1=y1';

tx_user=transdata1;

sp_data{ku}=tx_user;

end

%%

tx_data_final=zeros(size(sp_data{1}));

for ku=1:no_of_user

tx_data_final=tx_data_final+sp_data{ku};

end

%%

for ku=2:no_of_user

N1=N;

Taps=4;

p1=0.5/2.3;

p2=0.9/2.3;

p3=0.7/2.3;

p4=0.2/2.3;

gain1=sqrt(p1/2)*[randn(1,N1) + j*randn(1,N1)];

gain2=sqrt(p2/2)*[randn(1,N1) + j*randn(1,N1)];

gain3=sqrt(p3/2)*[randn(1,N1) + j*randn(1,N1)];

gain4=sqrt(p4/2)*[randn(1,N1) + j*randn(1,N1)];

tx_data_final=sp_data{ku-1}+sp_data{ku};

x11=tx_data_final(:);

x12=reshape(x11,1,length(x11));

i=1:length(x12);

%%

delay1=3;

for i=delay1+1:length(x12)

x13(i)=tx_data_final(i-delay1);

end

delay2=3;

for i=delay2+1:length(x12)

x14(i)=tx_data_final(i-delay2);

end

delay3=3;

for i=delay3+1:length(x12)

x15(i)=tx_data_final(i-delay3);

end

x1=reshape(x13,(no_of_sub+3),length(x13)/(no_of_sub+3));

x2=reshape(x14,(no_of_sub+3),length(x14)/(no_of_sub+3));

x3=reshape(x15,(no_of_sub+3),length(x15)/(no_of_sub+3));

ch1=repmat(gain1,(no_of_sub+3),1);

ch2=repmat(gain2,(no_of_sub+3),1);

ch3=repmat(gain3,(no_of_sub+3),1);

ch4=repmat(gain4,(no_of_sub+3),1);

data_channel=(tx_data_final).*ch1+x1.*ch2+x2.*ch3+x3.*ch4;

data_noise1=data_channel(:);

data_noise2=reshape(data_noise1,1,length(data_noise1));

end

%%

noise = 1/sqrt(2)*[randn(1,length(data_noise2)) + j*randn(1,length(data_noise2))];

snr = [0];

for i = 1:length(snr)

y = data_noise2 + (sqrt(1)*10^(-snr(i)/20))*noise; %Addition of Noise

data_received =y;

rx1=reshape(data_received,(no_of_sub+3),length(data_received)/(no_of_sub+3));

rx12=rx1';

rx13 = rx12(:,[(4:(no_of_sub+3))]);

rx14=rx13';

fft_data_received =fft(rx14);

channel_response=fft([gain1;gain2;gain3;gain4],no_of_sub);

data_equilized=fft_data_received.*conj(channel_response);

ku=no_of_user;

recdata11=(data_equilized'*(code{ku})')';

recdata12=real(recdata11)>0;

out_data=recdata12;

errors_user1= size(find([data{ku}- out_data]),2);

bit_errorx(i)= errors_user1/N;

end

bit_error_rate(ksub)=bit_errorx;

end

%%

clear x13 x14 x15

no_of_user=50;

sub_ch=[4 8 16];

N=10^3;

for ksub=1:length(sub_ch)

no_of_sub =sub_ch(ksub)

%%

length_mess=no_of_user*N;

walsh1=hadamard(no_of_sub);

walsh=REEDMULER(walsh1);

kux=1;

for ku=1:no_of_user

code{ku}=walsh(kux,:);

kux=kux+1;

if(kux==no_of_sub)

kux=1;

end

end

n = 6; k = 4; % Set codeword length and message length % for a [6,4] code.

%%

original_message=randint(1,length_mess,2);

locx=1;

locy=N;

for ku=1:no_of_user

data{ku}= original_message(locx:locy);

msg=data{ku};

mess= encode(msg,n,k,'cyclic'); % Code will be a binary column.

len=length(mess);

ele{ku}=randperm(len);

intr_lve{ku}=intrlv(mess,ele{ku});

datamod = 2*intr_lve{ku}-1;

user_data_mod{ku}=datamod';

locx=locy+1;

locy=locx+(N-1);

end

%%

for ku=1:no_of_user

data_user11=user_data_mod{ku};

spdata1_user1=data_user11*(code{ku});

spdata12=(spdata1_user1)';

ifftdata_user1=ifft(spdata12);

ifftdata12=ifftdata_user1';

y1=[ifftdata12(:,[(no_of_sub-2):no_of_sub]) ifftdata12];

transdata1=y1';

tx_user=transdata1;

sp_data{ku}=tx_user;

end

%%

tx_data_final=zeros(size(sp_data{1}));

for ku=1:no_of_user

tx_data_final=tx_data_final+sp_data{ku};

end

%%

for ku=2:no_of_user

N1=N*(n/k);

Taps=4;

p1=0.5/2.3;

p2=0.9/2.3;

p3=0.7/2.3;

p4=0.2/2.3;

gain1=sqrt(p1/2)*[randn(1,N1) + j*randn(1,N1)];

gain2=sqrt(p2/2)*[randn(1,N1) + j*randn(1,N1)];

gain3=sqrt(p3/2)*[randn(1,N1) + j*randn(1,N1)];

gain4=sqrt(p4/2)*[randn(1,N1) + j*randn(1,N1)];

tx_data_final=sp_data{ku-1}+sp_data{ku};

x11=tx_data_final(:);

x12=reshape(x11,1,length(x11));

i=1:length(x12);

%%

delay1=3;

for i=delay1+1:length(x12)

x13(i)=tx_data_final(i-delay1);

end

delay2=3;

for i=delay2+1:length(x12)

x14(i)=tx_data_final(i-delay2);

end

delay3=3;

for i=delay3+1:length(x12)

x15(i)=tx_data_final(i-delay3);

end

x1=reshape(x13,(no_of_sub+3),length(x13)/(no_of_sub+3));

x2=reshape(x14,(no_of_sub+3),length(x14)/(no_of_sub+3));

x3=reshape(x15,(no_of_sub+3),length(x15)/(no_of_sub+3));

ch1=repmat(gain1,(no_of_sub+3),1);

ch2=repmat(gain2,(no_of_sub+3),1);

ch3=repmat(gain3,(no_of_sub+3),1);

ch4=repmat(gain4,(no_of_sub+3),1);

data_channel=(tx_data_final).*ch1+x1.*ch2+x2.*ch3+x3.*ch4;

data_noise1=data_channel(:);

data_noise2=reshape(data_noise1,1,length(data_noise1));

end

%%

noise = 1/sqrt(2)*[randn(1,length(data_noise2)) + j*randn(1,length(data_noise2))];

snr = [0];

for i = 1:length(snr)

y = data_noise2 + (sqrt(1)*10^(-snr(i)/20))*noise; %Addition of Noise

data_received =y;

rx1=reshape(data_received,(no_of_sub+3),length(data_received)/(no_of_sub+3));

rx12=rx1';

rx13 = rx12(:,[(4:(no_of_sub+3))]);

rx14=rx13';

fft_data_received =fft(rx14);

channel_response=fft([gain1;gain2;gain3;gain4],no_of_sub);

data_equilized=fft_data_received.*conj(channel_response);

ku=no_of_user;

recdata11=(data_equilized'*(code{ku})')';

recdata12=real(recdata11)>0;

mess1=deintrlv(uint8(recdata12),ele{ku});

out_data= decode(double(mess1),n,k,'cyclic'); % Code will be a binary column.

errors_user1= size(find([data{ku}- out_data]),2);

bit_errorx1= errors_user1/N;

end

bit_error_rate1(ksub)=bit_errorx1;

end

figure,semilogy(sub_ch,bit_error_rate,'k<-.',sub_ch,bit_error_rate1,'g>-','linewidth',2);

axis([4 16 10^-1 10^0]);

legend('without inter ','with inter');

title('performance');

xlabel('SNR value');

ylabel('bit error rate');

grid on;