MATLAB: How to generate this signal

generatingsignal

how i can to generate this signal please help

Best Answer

Try this:
t = linspace(0, 40, 250);
f = 1*((t >= 10) & (t <= 20)) + (-1)*((t > 20) & (t <= 30));
figure(1)
plot(t, f)
axis([xlim -1.1 1.1])