【 MATLAB 】常用的离散时间序列的 Matlab 产生
【摘要】 单位样本序列
clcclearclose alln1 = 0;n2 = 5;n0 = 3; n = [n1:n2];x = [(n - n0) == 0]; stem(n,x,'filled');ylim([-1,2]);
改成一个函数:
function [x,n]=delta(n0,n1,n2);% generate x(n) = delta...
单位样本序列
-
clc
-
clear
-
close all
-
n1 = 0;
-
n2 = 5;
-
n0 = 3;
-
-
n = [n1:n2];
-
x = [(n - n0) == 0];
-
-
stem(n,x,'filled');
-
ylim([-1,2]);
改成一个函数:
-
function [x,n]=delta(n0,n1,n2);
-
% generate x(n) = delta(n - n0); n1 <= n <= n2
-
%_____________________________________________
-
%[x,n] = delta(n0, n1, n2);
-
%
-
n = [n1:n2];
-
x = [(n-n0) == 0];
命名为delta.m
新建一个脚本:
-
n0 = 3;
-
n1 = -3;
-
n2 = 6;
-
-
-
[x,n] = delta(n0,n1,n2);
-
stem(n,x,'filled');
-
ylim([-1,2]);
运行得到:
单位阶跃序列
直接写成函数形式吧:
-
function [x,n]=stepseq(n0,n1,n2);
-
% generate x(n) = u(n - n0); n1 <= n <= n2
-
%_____________________________________________
-
%[x,n] = stepseq(n0, n1, n2);
-
%
-
n = [n1:n2];
-
x = [(n-n0) >= 0];
新建一个脚本,测试:
-
clc
-
clear
-
close all
-
-
n0 = 3;
-
n1 = -3;
-
n2 = 6;
-
-
-
[x,n] = stepseq(n0,n1,n2);
-
stem(n,x,'filled');
-
ylim([-1,2]);
结果:
实值指数序列
为一般形式。
下面产生一个序列:
脚本代码:
-
clc
-
clear
-
close all
-
-
n = -3:10;
-
x = 0.9.^n;
-
-
stem(n,x,'filled');
-
xlabel('n');
-
ylabel('0.9^n');
-
xlim([-5,13]);
-
ylim([0,2]);
复指数序列
-
clc
-
clear
-
close all
-
-
n = 0:10;
-
x = exp( (2+3j)*n );
-
-
stem(n,x);
-
xlabel('n');
-
-
周期序列
-
clc
-
clear
-
close all
-
-
n = 0:10;
-
x = exp( (2+3j)*n );
-
-
subplot(2,1,1)
-
stem(n,x);
-
xlabel('n');
-
title('Not Period Sequence');
-
-
% the number of period
-
P = 5;
-
-
xtilde = x' * ones(1,P);
-
xtilde = xtilde(:)';
-
-
subplot(2,1,2);
-
stem(xtilde);
-
title('Period Sequence');
文章来源: reborn.blog.csdn.net,作者:李锐博恩,版权归原作者所有,如需转载,请联系作者。
原文链接:reborn.blog.csdn.net/article/details/83242660
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)