hmsheng
Joined: 17 Dec 2003 Posts: 212 Helped: 16 Location: China
|
18 Jul 2007 16:00 matlab spread spectrum |
|
|
|
|
Hi, friends, I write a matlab program to simulate the spread spectrum result. fft is used to view the spectrum of the modulated signal. The spectrum should be same with differenct sample points. In the matlab program, tstep and tstop will dicide the sample points. tstep=1e-9. When tstop changed the width of the spectrum will change too! So, there must be some problem in my program. Please help to find the problem. Thanks a lot.
Please change the tstop=1e-4 to tstop=2e-4 and compare the spectrum.
clear;
Nfft = 2^18; % fft points
% Create a 100MHz signal source
A = 1; % Amplitude of the signal
fc = 100e6; % Carrier frequency
tstep = 1e-9; fs = 1/tstep;
tstop = 1e-4;
t = 0:tstep:tstop-tstep;
vt = A*cos(2*pi*fc*t); % single tone signal source
Y = fft(vt,Nfft);
Pydb = 10*log10(Y.*conj(Y)/Nfft);
% Spread spectrum
Fspread = 30e3; Tspread = 1/Fspread;
Fd = fc*0.0025; % Frequency deviation
Fcss =fc+2*abs(mod(t+Tspread/4,Tspread)/Tspread*2*Fd-Fd)-Fd;
vtss = A*cos(2*pi*Fcss.*t); % Spread signal
Yss = fft(vtss,Nfft);
Pyssdb = 10*log10(Yss.*conj(Yss)/Nfft);
f = fs*(0:Nfft-1)/Nfft;
subplot(2,1,1), plot(f,Pydb,f,Pyssdb);
axis([9e7,11e7,-100,50]), grid;
xlabel('Frequecy (Hz)'), ylabel('Power (dB)');
subplot(2,1,2), plot(t,Fcss);
xlabel('Time (s)'), ylabel('Frequency (Hz)');
grid;
|
|