1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Matlab, for loop, sawtooth function

  1. Nov 16, 2011 #1
    1.Hi! i am having problems plotting a sawtooth waveform without the use of the sawtooth function in matlab. I am required to produce a sawtooth waveform with a duty cycle of 30% using nested loops (for loop within a for loop) i have managed to get the ramp function from one, for loop,therefore it is a unit step, however i cannot manage to get the waveform to come down at 30%. I need to know how to create another for loop within the for loop to bring it down at 30%. Any help out there? I even tried to use an if statement but this did nothing. I managed to get another vector in there but it was wrong.





    3. %SAWTOOTH WAVE PLOT

    y=0:0.2:1
    for j=0:0.2:1
    a=(j)+y
    end
    figure(1)
    plot(a,y)
     
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted



Similar Discussions: Matlab, for loop, sawtooth function
  1. For loops in Matlab (Replies: 22)

  2. MatLab for loops (Replies: 3)

  3. MATLAB "for loops" (Replies: 8)

Loading...