📄 sinusoid.m
字号:
%an example to generate a sinusoid signalclear;%magnitude is AA = 5;%f_sig is the frequency of the signal, T_sig is the corresponding periodf_sig = 3; T_sig = 1/f_sig;%T_max is the maximum number of timeT_max = 2*T_sig;%Ts is the sampling interval of the continuous time signal (Fs is sampling%rate)Ts = 1e-3; Fs = 1/Ts;%generate time vectort = -T_max:Ts:T_max;%a complicated way to generate the signal vector by setting the values of%the vector element by elementt_len = length(t);mid_point = (t_len+1)/2;for i = 1:t_len t_now = (i-mid_point)*Ts; cos_t(i) = A*cos(2*pi*f_sig*t_now);end%a much easier way to generate the signal vector by setting the vector%directly.vector_sig = A*sin(2*pi*f_sig*t);%plot the signalplot(t, cos_t);hold on; grid on;plot(t, vector_sig,'r');ylabel('x(t)');xlabel('t (sec)');ylim([-A*1.1, A*1.1]);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -