150 views (last 30 days)

Show older comments

James Tursa
on 25 Nov 2020

Not sure what you mean by "repeated at [2,10]". Maybe this:

y = mod(x,2);

ix = y > 1;

y(ix) = 2 - y(ix);

David Hill
on 25 Nov 2020

y=zeros(size(x));

for k=1:5

y(x>=(k-1)*2&x<(k-1)*2+1)=x(x>=(k-1)*2&x<(k-1)*2+1);

y(x>=2*(k-1)+1&x<2*k)=2-x(x>=2*(k-1)+1&x<2*k);

end

Bastian Arturo Romero Mardones
on 25 Nov 2020

You can use this function: https://es.mathworks.com/matlabcentral/fileexchange/83058-continuous-piecewise-function-linear-funcion-por-partes

x = [0:3:36];

y = [0 1 0 1 0 1 0 1 0 1 0 1 0];

sig = pwfun(x,y);

and create the waveform only with the intersection points.

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!