地心引力分享 http://blog.sciencenet.cn/u/zhengfan 探索地球深部之谜

博文

连续/离散时间信号图

已有 2882 次阅读 2017-12-14 10:42 |个人分类:MATLAB|系统分类:科研笔记| 数字信号处理图形

MATLAB代码如下:(参考书:Digital Signal Processing Using MATLAB, 3rd Edition 2011.下同)

连续时间信号:


t = 0:0.01:2;    % sample points from 0 to 2 in steps of 0.01

x = sin(2*pi*t); % Evaluate sin(2 pi t)

plot(t,x,'b');   % Create plot with blue line

xlabel('t in sec'); ylabel('x(t)'); % Label axis

title('Plot of sin(2\pi t)'); % Title plot





离散时间信号(火柴梗图):


n = 0:1:40;  % sample index from 0 to 20

x = sin(0.1*pi*n); % Evaluate sin(0.2 pi n)

Hs = stem(n,x,'b','filled'); % Stem-plot with handle Hs

set(Hs,'markersize',4); % Change circle size

xlabel('n'); ylabel('x(n)'); % Label axis

title('Stem Plot of sin(0.2 pi n)'); % Title plot



将两者画在同一个图上:


t = 0:0.01:2; % sample points from 0 to 2 in steps of 0.01

tx = sin(2*pi*t); % Evaluate sin(2 pi t)

plot(t,tx,'b'); % Create plot with blue line

hold on


n = 0:1:40;  % sample index from 0 to 20

nx = sin(0.1*pi*n); % Evaluate sin(0.2 pi n)

Hs = stem(n*0.05,nx,'b','filled'); % Stem-plot with handle Hs

set(Hs,'markersize',4); % Change circle size

hold off




画在两个图上同时显示:


t = 0:0.01:2; % sample points from 0 to 2 in steps of 0.01

tx = sin(2*pi*t); % Evaluate sin(2 pi t)

subplot(2,1,1);

plot(t,tx,'b'); % Create plot with blue line


n = 0:1:40;  % sample index from 0 to 20

nx = sin(0.1*pi*n); % Evaluate sin(0.2 pi n)

subplot(2,1,2);

Hs = stem(n*0.05,nx,'b','filled'); % Stem-plot with handle Hs

set(Hs,'markersize',4); % Change circle size







https://blog.sciencenet.cn/blog-3357000-1089603.html

上一篇:科研之路,从今天开始
下一篇:在iris官网上申请所需数据(以申请某一台站记录的波形为例)
收藏 IP: 121.195.114.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-4-19 07:56

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部