From help-request at octave dot org Mon Apr 10 11:47:51 2006 Subject: Re: square waves From: NZG To: Paul Kienzle Cc: Doug Stewart , help@octave.org Date: Mon, 10 Apr 2006 11:46:32 -0500 A generalized approach to Paul Kienzle's suggested method. ## v = pwms(t,period,duty) ## ## square pulse width modulation ## ## period in units of samples, duty is the fraction the pwm is "high". function v = pwms(t,period,duty) pw = period*duty; v = pulstran(t,(period -pw/2):period:length(t),'rectpuls',period*duty); endfunction NZG ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------