arraysmatlabsignal-processingperiodicity

Generating discrete time periodic signal in matlab


x[t] is a discrete time periodic signal defined as follows over one period

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

I want to generate this as a periodic signal in the interval [0,100] in Matlab. But, I am unable to write a code for this.


Solution

  • Maybe you can try arrayfun like below

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

    which gives

    x =
    
       1   2   1   2   3   1   2   3   4   1   2   1   2   3   1   2   3   4