i got this error : ??? Subscripted assignment dimension mismatch. Error in ==> crmapping at 6 iout(2:27,:)=idata(1:26,:); Error in ==> OFDMA512 at 36 [iout,qout] = crmapping(y,ylen,fftlength,nd);
1 view (last 30 days)
Show older comments
%/////////OFDMA///////////
clear all;close all;clc; %,,,,,,,,,,,,,System Parameters,,,,,,,,,,,,
fftlength = 512; nd = 6; BW = 5e6; FS = 2*BW; % Sampling Frequency % No. of Subcarriers NS = 512;
%,,,,,,,,,,,,,,,,,main program,,,,,,,,,,,,,,,,
% Input Generation x = rand(1,NS)>0.5; % Conversion of data from serial to parallel p = series2parallel(x,NS); % M ary Modulation of PSK and QAM M = 2; X = 0; for count1 = 2:1:7; if (M==2||M==4||M==16||M==64) M = M+X % M-ary modulation for producing y. if(M<=8) % Modulation for PSK y=modulate(modem.pskmod(M),p); else % Modulation for QAM y=modulate(modem.qammod(M),p); end ylen = length(y); %Applying Mapping %q_out = ofdma_mapping(y,ylen); [iout,qout] = crmapping(y,ylen,fftlength,nd); % Apply IFFT operation outifft = ifft(iout,qout); % Cyclic Prefix Addition cp(count1,:) = cyclicpad(outifft,64); % Length of CP cplength = length(cp); % Conversion of data from parallel to serial out = reshape(cp(count1,:),1,cplength); % Signal transmits through AWGN channel. ynoisy = awgn(out,100,'measured'); % Addition of Rayleigh Fading c = rayleighchan(1/1000,100,[0 2e-5],[0 -9]); rf = filter(c,ynoisy); % Conversion of data from serial to parallel p2 = series2parallel(rf,cplength); re_par = real(p2); % Remove cyclic prefix rcp(count1,:) = decyclicpad(p2,64); rcplength = length(rcp); % FFT zzfft = fft(rcp(count1,:),fftlength); %Apply Demapping qq_out = ofdma_demapping(zzfft,fftlength); outfft = qq_out; % %Applying IFFT % zfft = ifft(qq_out); if (M<=8) % Demodulation of PSK at Reciever z=demodulate(modem.pskdemod(M),outfft); else % Demodulation of QAM at Reciever z=demodulate(modem.qamdemod(M),outfft); end % Conversion of data from parallel to serial xdash = reshape(z,1,NS) berr = 0 ; for a = 1:1:NS; if (xdash(:,a) == x(:,a)) berr = 0; else berr = berr+1; end end tberr(count1,:) = berr; Eb_No = 0:1:NS-1; Eb_No = 0.4*Eb_No; if(M<=8) ber(count1,:) = berawgn(Eb_No,'psk',M,'nondiff'); Pe(count1,:) = erfc(sqrt(0.9*Eb_No)*sin(pi/M)); else ber1(count1,:) = berawgn(0.9*Eb_No,'qam',M); Pe(count1,:) = 2*((1-(1/sqrt(M)))*erfc(sqrt((1.5*Eb_No)/(M-1)))); end for init = 1:1:32 switch M end end end M= 2^count1; end
figure() % Plot SNR and BER semilogy(Eb_No,ber(2,:),'k',Eb_No,ber(3,:),'g',Eb_No,ber1(5,:),'b',Eb_No,ber1(7,:),'r'); axis([0 25 0.0001 1]); xlabel('SNR [dB]') ylabel('BER') legend('BPSK','QPSK','16-QAM','64-QAM') title('OFDMA')
figure() % Plot Error Probability semilogy(Eb_No,Pe(2,:),'k',Eb_No,Pe(3,:),'r',Eb_No,Pe(5,:),'b',Eb_No,Pe(7,:),'g'); axis([0 50 0.0001 1]); xlabel('SNR [dB]') ylabel('Probability of Error') legend('BPSK','QPSK','16-QAM','64-QAM') title('OFDMA') h = spectrum.periodogram; figure() HS = psd(h,outifft,'SpectrumType','twosided','NFFT',NS,'FS',FS); plot(HS) xlabel('Sampling Frequency (2×BW) in MHz') ylabel('Power Spectral Density [dBm/Hz]') title('OFDMA') grid off;
Answers (0)
See Also
Categories
Find more on Synchronization and Receiver Design in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!