利用matlab分别求出cos(2t)、cos(2t-1)、cos[2(t-1)]的傅里叶变换和傅里叶逆变换
时间: 2024-02-20 21:57:29 浏览: 200
以下是分别求出cos(2t)、cos(2t-1)、cos[2(t-1)]的傅里叶变换和傅里叶逆变换的MATLAB代码:
1. 求cos(2t)的傅里叶变换和傅里叶逆变换:
```
% 定义时间区间
t = -10:0.01:10;
% 定义函数
f = cos(2*t);
% 求傅里叶变换
F = fft(f);
% 求能量谱密度
PSD = F.*conj(F)/length(f);
% 求频率
freq = 1/(t(2)-t(1))*(-length(f)/2:length(f)/2-1)/length(f);
% 画出函数和能量谱密度图像
figure(1);
subplot(2,1,1);
plot(t,f);
xlabel('Time (s)');
ylabel('Amplitude');
title('cos(2t)');
grid on;
subplot(2,1,2);
plot(freq,PSD);
xlabel('Frequency (Hz)');
ylabel('Power');
title('Power Spectral Density');
grid on;
% 求傅里叶逆变换
f_recon = ifft(F);
% 画出重构的函数图像
figure(2);
plot(t,f_recon);
xlabel('Time (s)');
ylabel('Amplitude');
title('Reconstructed cos(2t)');
grid on;
```
2. 求cos(2t-1)的傅里叶变换和傅里叶逆变换:
```
% 定义时间区间
t = -10:0.01:10;
% 定义函数
f = cos(2*t-1);
% 求傅里叶变换
F = fft(f);
% 求能量谱密度
PSD = F.*conj(F)/length(f);
% 求频率
freq = 1/(t(2)-t(1))*(-length(f)/2:length(f)/2-1)/length(f);
% 画出函数和能量谱密度图像
figure(1);
subplot(2,1,1);
plot(t,f);
xlabel('Time (s)');
ylabel('Amplitude');
title('cos(2t-1)');
grid on;
subplot(2,1,2);
plot(freq,PSD);
xlabel('Frequency (Hz)');
ylabel('Power');
title('Power Spectral Density');
grid on;
% 求傅里叶逆变换
f_recon = ifft(F);
% 画出重构的函数图像
figure(2);
plot(t,f_recon);
xlabel('Time (s)');
ylabel('Amplitude');
title('Reconstructed cos(2t-1)');
grid on;
```
3. 求cos[2(t-1)]的傅里叶变换和傅里叶逆变换:
```
% 定义时间区间
t = -10:0.01:10;
% 定义函数
f = cos(2*(t-1));
% 求傅里叶变换
F = fft(f);
% 求能量谱密度
PSD = F.*conj(F)/length(f);
% 求频率
freq = 1/(t(2)-t(1))*(-length(f)/2:length(f)/2-1)/length(f);
% 画出函数和能量谱密度图像
figure(1);
subplot(2,1,1);
plot(t,f);
xlabel('Time (s)');
ylabel('Amplitude');
title('cos[2(t-1)]');
grid on;
subplot(2,1,2);
plot(freq,PSD);
xlabel('Frequency (Hz)');
ylabel('Power');
title('Power Spectral Density');
grid on;
% 求傅里叶逆变换
f_recon = ifft(F);
% 画出重构的函数图像
figure(2);
plot(t,f_recon);
xlabel('Time (s)');
ylabel('Amplitude');
title('Reconstructed cos[2(t-1)]');
grid on;
```
以上代码可以在MATLAB中运行,得到对应的结果。
阅读全文
相关推荐














