N=1024
fs=1024
t=0:1/fs:(N-1)/fs
x=sin(200*pi*t)
%原始波形
figure
plot(t,x)%%%波形
set(gca,'燃运悄xlim',[0,0.2],'ylim',[-1.3,1.3])
title('原始波形图皮渣')
%频谱分析
a=fft(x)
a=abs(a)*2/N
f=0:fs/N:(N-1)*fs/N
figure
plot(f,a)
title('幅频谱图'悄睁)
%逆变换后时域图
b=ifft(a)*N/2
figure
plot(t,b)
set(gca,'xlim',[0,0.2],'ylim',[-1.3,1.3])
title('反变换后波形')
【1】 MATLAB一般绘制公式对应的图形是二维的,例如二维绘图函数,三维绘图原理类似。
常用的二维绘图函数:
plot(x,y,‘s’)
x,y是向量,分别表示点集的横坐标和纵坐标,s表示线型、颜色、点形
•title(‘加图行埋形标题')
•xlabel('加X轴标记')
•陵姿ylabel('加Y轴标记')
•text(X,Y,'添加文本')
•grid on 加网格线
•text(x,y,‘string’) adds the string in quotes(引号) to the location specified by the
point (x,y).
•\bullet ·
•\pi π
•\rightarrow
右箭头
•EdgeColor -- Color of the rectangle's edge
(none by default).
•‘EdgeColor’尺带绝 ,‘red’
【2】波形图如图所示:
假设你已经定义了f(t)的函数,可以通过冲庆以下巧弊步骤得到f(-t)的波形:1、创建一个时间轴t,可以使用linspace函数或者colon运算符来生成一孝判族段时间范围。
2、计算f(t)的值,即f(t) = yourFunction(t)。
3、计算f(-t)的值,即fNegative = yourFunction(-t)。
4、使用plot函数分别绘制f(t)和f(-t)的波形,例如plot(t, f)和plot(t, fNegative)。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)