Prev: Zip question: Where are all the extra characters coming fromupon unzipping?
Next: SwingWorker threading issue?
From: Andreas Leitgeb on 28 Oct 2009 08:17 Andreas Leitgeb <avl(a)gamma.logic.tuwien.ac.at> wrote: > harryos <oswald.harry(a)gmail.com> wrote: >> On Oct 28, 2:13 pm, Arved Sandstrom <dces...(a)hotmail.com> wrote: >> > the argument is in radians, not degrees. So cos (20pi) = 1. >> if I use m1=Math.cos(Math.PI*2*10*t*180/Math.PI) >> will that do the conversion? > If with 20pi you really thought of an angle in degrees, > (that would be slightly larger than the angles of an > equilateral triangle), then Math.PI*2*10*t*180/Math.PI > or just: 3600*t does it. Damn, slipped into the trap, myself. if 20pi was an angle in degrees, then the argument to cos had rather be Math.PI*2*10*t*Math.PI/180, that is (pi²/9)·t sorry for confusion.
From: jimgardener on 28 Oct 2009 09:13 On Oct 28, 5:17 pm, Andreas Leitgeb > if 20pi was an angle in degrees, then the argument to > cos had rather be Math.PI*2*10*t*Math.PI/180, that > is (pi²/9)·t > the equation looks like an expression for a stationary signal with frequencies 10,25,50 and 100.(.I am not very familiar with signal processing stuff.but I remember seeing this as an example for stationary signal.)If you plot the x(t) against different values of t (time) then you will only get a straight line parallel to t axis if you use m1=Math.cos(Math.PI*2*10*t); m2=Math.cos(Math.PI*2*25*t); m3=Math.cos(Math.PI*2*50*t); m4=Math.cos(Math.PI*2*100*t); y=m1+m2+m3+m4; May be you need some conversion to get a good plot..Can someone familiar with this domain comment? jim
From: Andreas Leitgeb on 28 Oct 2009 09:59 jimgardener <jimgardener(a)gmail.com> wrote: > the equation looks like an expression for a stationary signal with > frequencies 10,25,50 and 100.(.I am not very familiar with signal > processing stuff.but I remember seeing this as an example for > stationary signal.)If you plot the x(t) against different values of t > (time) then you will only get a straight line parallel to t axis if > you use > m1=Math.cos(Math.PI*2*10*t); > m2=Math.cos(Math.PI*2*25*t); > m3=Math.cos(Math.PI*2*50*t); > m4=Math.cos(Math.PI*2*100*t); > y=m1+m2+m3+m4; > May be you need some conversion to get a good plot..Can someone > familiar with this domain comment? Of course it depends on the sample rate of t: is it watched only in discrete units? "Hey, I marked the top position of a wheel and then I rolled it two complete rotations forward, and guess what? The mark was on top, not only afterwards but also at halftime!"
From: Patricia Shanahan on 28 Oct 2009 10:49 jimgardener wrote: > On Oct 28, 5:17 pm, Andreas Leitgeb >> if 20pi was an angle in degrees, then the argument to >> cos had rather be Math.PI*2*10*t*Math.PI/180, that >> is (pi�/9)�t >> > > the equation looks like an expression for a stationary signal with > frequencies 10,25,50 and 100.(.I am not very familiar with signal > processing stuff.but I remember seeing this as an example for > stationary signal.)If you plot the x(t) against different values of t > (time) then you will only get a straight line parallel to t axis if > you use > m1=Math.cos(Math.PI*2*10*t); > m2=Math.cos(Math.PI*2*25*t); > m3=Math.cos(Math.PI*2*50*t); > m4=Math.cos(Math.PI*2*100*t); > y=m1+m2+m3+m4; > > May be you need some conversion to get a good plot..Can someone > familiar with this domain comment? > > jim The multiplication by Math.PI*2 in m1=Math.cos(Math.PI*2*10*t); may itself have been a messed up conversion from degrees to radians. Sampling angles of the form 10*t degrees would be quite reasonable, and yield different cosines. I would do the conversion use Math.toRadians. However, from first principles a complete rotation is 360 degrees and 2*pi radians, so x degrees is 2*pi*x/360 radians. Forgetting the division by 360 would make a big difference in how the angles behave. Patricia
From: Roedy Green on 4 Nov 2009 10:20
On Wed, 28 Oct 2009 02:07:08 -0700 (PDT), harryos <oswald.harry(a)gmail.com> wrote, quoted or indirectly quoted someone who said : >hi >I was trying to calculate the value of >x(t)=cos(2*pi*10*t)+cos(2*pi*25*t)+cos(2*pi*50*t)+cos(2*pi*100*t) for >some values.I wrote this code for the usual gotchas, (e.g. confusing radians/degrees) see http://mindprod.com/jgloss/trigonometry.html -- Roedy Green Canadian Mind Products http://mindprod.com An example (complete and annotated) is worth 1000 lines of BNF. |