Author Topic: Need Help - Creating a Sawtooth and Square Wave  (Read 437 times)

Offline Bink

  • Newbie
  • *
  • Posts: 1
  • Matlab Forum
    • View Profile
Need Help - Creating a Sawtooth and Square Wave
« on: October 15, 2010, 07:38:40 PM »
Hi all,

I have just stated using Matlab and would really appreciate a bit of help to get me started.

I want to create a Sawtooth and Square wave just like the ones which are shown here.
http://www.swarthmore.edu/NatSci/echeeve1/Class/e71/E71L1/E71L1_3.gif

The task is to generate the first 100 samples of those two sequences  when:

Sampling Frequency (fT) = 20kHz
Peak Value (A) = 7
Period (N) = 13

And for the square wave:

Duty cycle = 60%

I will also need to give a value for the Length of sequence (L) so lets set that as 30 like in the diagrams.

So far I have got:

L=input('type in the sequence length=');
A=input('type in the peak levels=');
N=input('type in the period=');
fT=20000;
t=0:1/fT:L;
x = sawtooth(2 * pi * t);
stem (t , x); axis ( [ 0 L -A A ] );

I realise that I have not used the value Period (N) but I am unsure how this fits in mathematically to the sequence. I hope that is all clear and any help would be greatly appreciated.



Matlab and SimuLink Development Forum

Need Help - Creating a Sawtooth and Square Wave
« on: October 15, 2010, 07:38:40 PM »