On 2/10/2012 7:03 AM, Tanveer Awal wrote:
> I want to plot sine wave with variation of period specified by the
> periods array(60,60,50,40,30,30,20,10s -> for total 300 second)
> sequentially. Although the following code plots sine wave with amplitude
> delta, when the period changes, sometimes its phase changes
> unexpectedly. Please help me to find out the problem
...
Don't have time (or more accurately, inclination) to try to debug your
code specifically but what you need is to find the proper phase shift to
match the quadrant and point in the previous frequency and the new
frequency that have the same magnitude and slope at the junction point
instead of just the magnitude difference you're doing. As you can see,
you're picking up in the wrong quadrant even though you've matched the
amplitude by what making an additive delta; that's not sufficient in of
itself.
Descriptively, you need theta1 and theta2 where theta1 is the present
phase angle at the end of the present segment and then find theta2 such
that it is in both the same quadrant and that inverse sine of that new
phase angle is determined by the magnitude.
--