Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
![]() |
#1 |
初级会员
注册日期: 2019-03-24
帖子: 1
声望力: 0 ![]() |
![]()
这是有关毕设课题的程序,要求是生成chirp函数的时域和频域图,但我Matlab只是入门级别,也不会编,望熟悉这方面的人能帮忙看看这段程序的问题,谢谢!
![]() A = 1; % pulse amplitude [V] smp = 1024; Tmin = -4e-9; Tmax = 4e-9; N = smp; f0 = 3e+9; Tc = 10e-9; Bc = 300e+6; miu = Bc/Tc; N >= (5e+8)/Bc; n = 0:N-1; t=linspace(Tmin,Tmax,smp); % Inizialization of the time % axischirpchirp % -------------------------------------------- % Step One - Pulse waveform in the time domain % -------------------------------------------- % Pulse waveform definition pulse = A.*cos(2.*pi.*(f0+n.*Bc).*t+pi.*miu.*t.^2); % ------------------------------------------- % Step Two - Analysis in the frequency domain % ------------------------------------------- dt = Tc / smp; % sampling period fs = 1/dt % sampling frequency N = smp; % number of samples (i.e. % size of the FFT) df = 1 / (N * dt); % fundamental frequency X=fft(pulse,N); % double-sided MATLAB % amplitude spectrum X=X/N; % conversion from MATLAB % spectrum to Fourier X1=fftshift(X); % ----------------------------- % Step Three - Graphical output % ----------------------------- % Time Domain Representation figure(1); PT=plot(t,pulse); set(PT,'LineWidth',[2]); AX=gca; set(AX,'FontSize',12); T=title('时域'); set(T,'FontSize',14); X=xlabel('时间 [s]'); set(X,'FontSize',14); Y=ylabel('幅度 [V]'); set(Y,'FontSize',14); hold on % Frequency Domain Representation figure(2); f=linspace((-fs/2),(fs/2),N); PF=plot(f,abs(X1)); set(PF,'LineWidth',[2]); AX=gca; set(AX,'FontSize',12); T=title('频域'); set(T,'FontSize',14); X=xlabel('频率 [Hz]'); set(X,'FontSize',14); Y=ylabel('幅度 [dB]'); set(Y,'FontSize',14); hold on |
![]() |
![]() |