figure(1) hold on subplot(2,1,1) plot(t1,x1,'-r') legend('采样间隔1.6ms'); title('时域采样结果') subplot(2,1,2) plot(t2,x2,'-b') legend('采样间隔2.5ms');
load work_dt1.csv load work_dt2.csv
figure(2) subplot(2,1,1) hold on plot(work_dt1(:,2),work_dt1(:,1),'-r') legend('采样间隔1.6ms') title('频谱绘制') subplot(2,1,2) hold on plot(work_dt2(:,2),work_dt2(:,1),'-b') legend('采样间隔2.5ms')
function [t,x,N] = xtime(dt) T = 2; % 采样总时间为2s,原点两边各采样1s N = floor(T*1000/dt); x = zeros(1,N); t = zeros(1,N); for i=1 : N t(i) = -T/2+(i-1)*dt/1000; x(i) = 1/pi/t(i)*sin(300*t(i)); end end