Sawtooth and square wave generation
Afficher commentaires plus anciens
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
Réponses (0)
Catégories
En savoir plus sur MATLAB Coder dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!