换能器的带宽决定了滤波器特性,用hamming窗来做。发射是正弦脉冲,仿真实际发出的信号
clc;clear all;close all;
%% 100KHz方波加载到1MHz的余弦波上,求fft 脉冲调制
n = 7;% 脉冲数
f_square = 1/n*1e6/2; %100KHz
f_cosine = 1e6; %1MHz
Fs = 5e7; %采样率
Ts = 1/Fs; %采样周期
L = 1e3; % Length of signal
t = (1:L-1)*Ts; % Time vector
phi = 0;
window = 1:ceil(1/f_square*Fs);
temp = 0.5 + square(2*pi*f_square*t)/2; %包络
temp2 = sin(2*pi*f_cosine*t+phi); %载波
y = temp.*temp2; %调制后
% plot(y)
y_bandpass = filter(hamming300J(Fs,0.9,1.1),y);
[f,Y] = FFT_transform(temp(window),length((window)),Fs); %单边fft调试
%%
figure(1);
subplot(211);plot(t(window),temp(window));title('100KHz方波包络波形'),xlabel('时间'),ylabel('振幅')%,ylim([-2,2]);
subplot(212);plot(t(window),temp2(window));title('1MHz余弦载波波形'),xlabel('时间'),ylabel('振幅')%,ylim([-2,2]);
%%