clc;clf;clear; [music, fs, nbits] = wavread('cap4th.wav'); N=length(music); %计算数据点 if mod(N,2)==0; N=N; else music(N)=[]; N=N-1; end; tx=(0:N-1)/fs; %原信号的数据时刻点 subplot(321); plot(tx,music); title('原信号波形'); xlabel('t'); sound(music,fs); xf=fft(music); %求频谱 fx=(0:N/2)*fs/N; %频谱图刻度 subplot(322); plot(fx,abs(xf(1:N/2+1))); title('原信号频谱图'); xlabel('Hz'); ylabel('幅值'); %对原信号进行插值运算 y1=zeros(1,4*N); %插零 N1=length(y1); y1([1:4:N1])=music; tx1=(0:N1-1)/(4*fs); subplot(323); plot(tx1,y1); title('插零后信号波形'); xlabel('t'); sound(y1,4*fs); xf1=fft(y1); % 求频谱 fx1=(0:N1/2)*4*fs/N1; %频谱图刻度 subplot(324); plot(fx1,abs(xf1(1:N1/2+1))); title('插零后信号频谱图'); xlabel('Hz'); ylabel('幅值'); %对原信号进行采样 k=[1:N/4]; y2=music(4*k); % 抽取的数据 N2=length(y2) tx2=(0:N2-1)/(fs/4); subplot(325); plot(tx2,y2); title('采样后信号波形'); xlabel('t'); sound(y1,4*fs); xf2=fft(y2); % 求频谱 fx2=(0:N2/2)*(fs/4)/N2; % 频谱图刻度 subplot(326); plot(fx2,abs(xf2(1:N2/2+1))); title('采样后信号频谱图'); xlabel('Hz'); ylabel('幅值'); |