Sawtooth and square wave generation

P = 1e-3;
n = 200;
Ts = P/n;
x = 0:Ts:P-Ts;
f = 1/P;
y = cos(2 * pi * f * x);
y=y*2^7;
y=fix(y);
plot(x,y)
I need to generate waves for a project am doing with VHDL. I used the above code to get the sine wave with 200 points and the period (1e-3). I want to do the same for sawtooth and square waves but not sure what am doing wrong. When i try to edit the above code to fit the sawtooth and square i just get a straight line. What do i change to generate the sawtooth and the square?
Thanks in advance

Answers (0)

Categories

Find more on MATLAB Coder in Help Center and File Exchange

Asked:

on 5 Dec 2018

Community Treasure Hunt

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

Start Hunting!