matlab高手来。菜鸟求帮助

设信号x(n)={1,2,3,4,5,3,3,3}.分别将其以5.8.12为周期进行周期延拓,给出6个周期。求matlab运行代码。

高手来了,帮你做个复杂点儿的,可以任意周期拓展,程序如下:
clear;
clc;
x = [1 2 3 4 5 3 3 3];
y = [];
period = input('input your period(5,8,12): ');
if period<=length(x)
for ii = 1:6
y = [y,x(1:period)];
end
else
%%%%%% 如果周期大于x的长度 %%%%%%%%
n = ceil(period/length(x)); %%%%% 首先确定x需要扩展的次数
xx = [];
for ii = 1:n
xx = [xx,x];
end
for ii = 1:6
y = [y,xx(1:period)];
end
end
y
plot(y) %%%% 画图
有问题欢迎追问,没问题请采纳
copyright(c) cxd1301
温馨提示:答案为网友推荐,仅供参考
相似回答