MATLAB Answers

kacha m

Sawtooth and square wave generation

Asked by kacha m
on 5 Dec 2018
P = 1e-3;
n = 200;
Ts = P/n;
x = 0:Ts:P-Ts;
f = 1/P;
y = cos(2 * pi * f * x);
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


Sign in to comment.

0 Answers