oh you are so right thank you very much.
zorro i have correct what you told me but now i have a new problem matlab says "out of memory"
"
Out of memory. Type HELP MEMORY for your options.
Error in Untitledquestion (line 12)
td=(Ts:Ts:1)';% Time vector(data)
"
my code is now looking like this:
clear all
close all
clc
fcarr=10.7e+6;% Carrier frequency(Hz)
fs=2*4*fcarr; %sample fequency
Fn=fs/2; % Nyquist frequency
Rb=100e+3; %bit/sec
Tb=1/Rb; %bit time
Ts=1/fs;%sampling time
td=(Ts:Ts:1)';% Time vector(data)
%%%%%%%%%%%%%%%%%%% transmiter %%%%%%%%%%%%
%%%% main chain of bits %%%%
data=sign(randn(1,Rb));
data1=ones(Tb/Ts,1)*data;
data2=data1
);
%%%% I chain of bits= odd bits %%%%
idata=data(1:2:length(data));
idata1=ones(2*Tb/Ts,1)*idata;
idata2=idata1
);
%%%% Q chain of bits= even bits %%%%
qdata=data(2:2:length(data));
qdata1=ones(2*Tb/Ts,1)*qdata;
qdata2=qdata1
);
%%%% generate carriers sin and cos %%%%
tiq = [Ts*2:Ts*2:1]';% Time vector for I and Q symbols(transpose)
twopi_fc_t=2*pi*fcarr*td;
ccos=cos(twopi_fc_t);
csin=sin(twopi_fc_t);
%%% modulation proccess %%%%
i_cos=ccos.*idata2;
q_sin=csin.*qdata2;
sumiq=q_sin+i_cos;
sumiq=0.7*sumiq;%reduce gain to keep output at +/- one
% fft of sumiq %%
[YfreqDomain,frequencyRange] = positiveFFT(sumiq,fs);
figure;
stem(frequencyRange,abs(YfreqDomain));
xlabel('Freq (Hz)')
ylabel('Amplitude')
title('the positive FFT of sumiq')
grid
Gsumiq=sumiq.*sumiq;
%% %%fft of Gsumiq %%
[YfreqDomain,frequencyRange] = positiveFFT(Gsumiq,fs);
figure;
stem(frequencyRange,abs(YfreqDomain));
xlabel('Freq (Hz)')
ylabel('Amplitude')
title('the positive FFT of Gsumiq')
grid
Hsumiq=Gsumiq.*Gsumiq;
%% %%fft of Hsumiq %%
[YfreqDomain,frequencyRange] = positiveFFT(Hsumiq,fs);
figure;
stem(frequencyRange,abs(YfreqDomain));
xlabel('Freq (Hz)')
ylabel('Amplitude')
title('the positive FFT of Hsumiq')
grid
i used function called positiveFFT and the function code is:
function [X,freq]=positiveFFT(x,Fs)
N=length(x); %get the number of points
k=0:N-20000; %create a vector from 0 to N-1
T=(N-20000)/Fs; %get the frequency interval
freq=k/T; %create the frequency range
X=fft(x); % normalize the data
%only want the first half of the FFT, since it is redundant
cutOff = ceil(N/2);
%take only the first half of the spectrum
X = X(1:cutOff);
freq = freq(1:cutOff);
can you or any one else can tell me what can i do? i dont want to change the frequencies and rates.