clc,clear;
Fs = 1000; % 采样频率
f1=10*105;
f2=100*105;
amp=1
T = 1/Fs; % 采样周期
L = 790; % 信号长度
t = (0:L-0.001)*(pi); % 时间向量
phase=0;
S = amp*cos((2*pi*f1*t)+phase)
X = amp*cos((2*pi*f2*t)+phase)
Y=S+X;
Z=S.*X;
figure %时域图
subplot(2,2,1)
plot(t,S,"R","linewidth",1);xlabel("S(t)");ylabel("Amplitude")
title("Signal_1)")
% plot(1000*t(1:50),X(1:50),"R","linewidth",1);xlabel('t (milliseconds)')
% ylabel('X(t)')
% title('Signal Corrupted with Zero-Mean Random Noise')
subplot(2,2,2)
plot(t,X,"Blue","linewidth",1);xlabel("X(t)");ylabel("Amplitude")
title("Signal_1)")
subplot(2,2,3)
plot(t,Y,"Black","linewidth",1);xlabel("Y(t)");ylabel("Ampltitude")
title("Adding the two Signals")
subplot(2,2,4)
plot(t,Z,"Green","linewidth",1);xlabel("Z(t)");ylabel("Ampltitude")
title("Multiplying the two Signals")
% subplot(2,2,2)
% plot(1000*t(1:5),S(1:50),"Blue","linewidth",1)
% title("Secend Signal")
% xlabel("t (millisecond")
% ylabel("S(t)")
figure %频域图
a = fftshift(fft(X));
P2 = abs(a/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = Fs*(0:(L/2))/L;
subplot(2,2,1)
plot(f,P1,"Black","linewidth",1);xlabel('f (Hz)');ylabel('Amp')
title('Frequency Spectrum of Signal_1')
b = fftshift(fft(S));
P2 = abs(b/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
subplot(2,2,2)
plot(f,P1,"Green","Linewidth",1);xlabel('f (Hz)');ylabel('Amp')
title('Frequency Spectrum of Signal_2')
c = fftshift(fft(Y));
P2 = abs(c/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = Fs*(0:(L/2))/L;
subplot(2,2,3)
plot(f,P1,"Blue","linewidth",1);xlabel('f (Hz)');ylabel('|P1(f)|')
title('Frequency Spectrum of Adding two Signals')
d = fftshift(fft(Z));
P2 = abs(d/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = Fs*(0:(L/2))/L;
subplot(2,2,4)
plot(f,P1,"Red","linewidth",1);xlabel('f (Hz)');ylabel('|P1(f)|')
title('Frequency Spectrum of Multiplication')

诉说你的笑
- 粉丝: 58
最新资源
- 永磁同步电机SVPWM弱磁控制仿真Simulink模型研究:前馈弱磁法及其应用 v2.5
- 电力电子领域永磁同步电机SVPWM算法故障诊断与容错控制的Simulink仿真研究 - SVPWM 实用版
- Java语言Post请求的request只可以读取一次的问题解决
- Java多线程:Runnable与Thread的比较
- 电源领域PFM与PWM混合调制LLC全桥谐振变换器闭环仿真模型解析
- 基于Python实现BP神经网络识别手写字体源码
- 基于MATLAB的单相双极性SPWM逆变电路设计与仿真实现
- Comsol纳米摩擦发电机仿真:基于静电场的电极材料电势与电场分布计算
- 电子相册制作平台源码项目说明
- 使用robot_localization实现传感器融合的深入分步教程
- COMSOL模拟中晶界介电特性的电击穿与电树枝发展
- 毕业设计智能电网级联故障建模研究 Matlab完整源码带说明文档
- Comsol流固耦合仿真模型:多物理场计算揭示速度、压力、位移与应力分布
- 土柱单向冻结与冻融循环中水热力三场耦合的COMSOL仿真及隔水层影响研究
- ArcGIS Editor for OSM 10.0-0010.8
- Comsol反应器仿真模型:多物理场耦合下的温度、速度与浓度分布研究 - Comsol
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



评论30