0

x[t] 是一个离散时间周期信号,在一个周期内定义如下

x[t] = {1 , 2 , 1 , 2 , 3 , 1 , 2 , 3 , 4.....}

我想在 Matlab 中将其生成为区间 [0,100] 中的周期性信号。但是,我无法为此编写代码。

4

2 回答 2

1

在 matlab 中,如果要生成周期性信号,有很多方法,其中之一是:

%x is array that represent discrete time signal.
%y is generated periodic signal 
%n the number of periods

temp=x'*ones(1,n);
y=temp(:);
% where x' is transpose of x.
% if we suppose x=[1,2,3]
% if we want to repeat it five times we can say n = 5
% then temp will equal [ 1 1 1 1 1
%                        2 2 2 2 2
%                        3 3 3 3 3]
%fianlly y will equal [1 2 3 1 2 3 1 2 3 1 2 3 1 2 3]
于 2021-05-01T12:19:22.980 回答
0

也许你可以尝试arrayfun如下

X = arrayfun(@(k) 1:k, 2:4, "UniformOutput",false);
x = repmat([X{:}],1,2);

这使

x =

   1   2   1   2   3   1   2   3   4   1   2   1   2   3   1   2   3   4
于 2021-05-01T22:29:57.063 回答