Triangular wave form plot

4 vues (au cours des 30 derniers jours)
Rashmil Dahanayake
Rashmil Dahanayake le 9 Déc 2013
Hi, I'm trying to generate a 140Hz triangular wave.
Following code produce the correct plot up to 100HZ. Once I enter the value beyond 100hz (eg 140hz) the plot doesn't seems to be correct.
t=0:.001:1.5 ;
x = sawtooth (2 * pi * 140 * t , 0.5); % 0.5 specify a symmetric triangular shape
plot(t,x); axis ( [ 0 0.01 -1 1 ] );
Is it some thing to do with the code of the plot figure settings?

Réponse acceptée

Walter Roberson
Walter Roberson le 9 Déc 2013
sawtooth() already does a 2*pi conversion internally. A value of 1 for time corresponds to one full cycle of the triangle wave. Your pre-multiplication by 2*pi is throwing that off.
  1 commentaire
Rashmil Dahanayake
Rashmil Dahanayake le 10 Déc 2013
HI Walter, I do not think what you mentioned about in built 2*pi conversion in sawtooth() is correct.
In fact you can try it out urself plotting a 4Hz triangular wave just for testing purposes. t=0:.001:1; x = sawtooth (2 * pi * 4 * t , 0.5); plot(t,x);
By further investigating I found out that the sample frequency caused the problem in high frequency sawtooth signals.
ie use t=0:.0001:1 instead 0:.01:1

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Line Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by