[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: square waves
From: |
NZG |
Subject: |
Re: square waves |
Date: |
Tue, 11 Apr 2006 12:24:16 -0500 |
User-agent: |
KMail/1.8.3 |
> What is wrong with the following?
Nothing at all, it's quite elegant actually.
thank you.
NZG
> axis([-0.1 1.1 -1.1 1.1])
> t=[0:0.001:1];
>
> # A 7 Hz square wave sampled at 1kHz with a .25 duty cycle
> plot(t,square(2*pi*t*7,0.25))
>
> # A 7 Hz sine wave
> plot(t,sin(2*pi*t*7))
>
> If you are using really coarse sampling then you are probably better
> off using a stem plot:
>
> t=[0:0.01:1];stem(t,square(2*pi*t*7,0.25))
>
> Stairs is misleading because of the aliasing.
>
> t=[0:0.01:1];stairs(t,square(2*pi*t*7,0.25))
>
> If you just want to plot the edges, then you can use e.g.,
>
> f=7;duty=0.25;
> t=[[0:1/f:1];[0:1/f:1]+duty/f](:);
> stairs(t,(-1).^[0:length(t)-1])
>
> - Paul
>
>
>
> -------------------------------------------------------------
> 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
> -------------------------------------------------------------
-------------------------------------------------------------
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
-------------------------------------------------------------
Message not available