Python Forum
Creating Data Set for Changing Oscillation Motion
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Creating Data Set for Changing Oscillation Motion
#1
Hello,
I need to create a set of data points that are essentially x and y values for a graph of position vs time. the x values range from 0 to 40 in seconds and the y values correspond to changing oscillatory motion. For example from 0 to 5 seconds I want a wave function with a frequency of 0.5 Hz then from 5 to 10 seconds I want to increase the frequency to 1.0 Hz. My position is what is changing to mimic sinusoidal waveform similar to a mass on a spring starting from a position of zero.

I'm not as concerned with the amplitude i.e. it could be 1 to -1. I thought I could do this using interpolation but i'm not sure how.

This is how it was done for a more simple motion in the past:
def synth_sledge():
    seconds = np.arange(0, 15, 1/1000)
    #evenly spaced values within a given interval
    e = 0.00000001
    points = np.array([
        [0, 0],
        [0+e, 0],
        [5, 0],
        [5+e, 0],
        [15, 6],
        [15+e, 6],
        ])
    pos = scipy.interpolate.interp1d(points[:,0],points[:,1], kind='quadratic')(seconds)
    return seconds, pos

t, x = synth_sledge()
x=scipy.ndimage.gaussian_filter(x, 50)
I'm really new to python and any help would be appreciated thanks!
Reply
#2
Why are you trying to do interpolation rather than just using sin or cos with the right values? Of course you can vary the frequency however you like. Having said that, a mass on a spring isn't going to oscillate with an increasing frequency like that on its own - maybe it's possible with a driving force, but I remember little about driven oscillators.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Changing the content of the table and saving the new data into another file femke_pythonquestion123 1 1,610 Sep-18-2020, 12:06 PM
Last Post: femke_pythonquestion123
  Planetary Motion Simulation kprov 1 8,852 May-25-2019, 06:38 PM
Last Post: Aziadocs

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020