Saturday, 15 August 2015

Python : creating an array, weighed by sine function -


I can create an array of 100 Equally distance number from 0 to 30 - It is possible to get an array of 100 numbers from 0 to 30, which can be equally distinction -

  theta = linspace (0,30,100)  

Is not weighed, but by its sign function ??

Explanation: Here's a picture to give you a ambiguous idea of ​​what you want theta which I defined , Selects the number evenly (like the first picture). I want the array to be weighed by its sign function. As the number of 0 to 30 increases, their sign (value) increases, so I want to take the higher number more often (like a second picture) in my array -

Enter image details here

I think I got your solution, it takes an original linear line of space and takes it sign , then it brings back the array so that Linear array As is the same end.

np import as matplotlib.pyplot plt def sinespace as import (m = 90, n = 10): x = np.linspace (0, m, n) s = Np.sin (np.deg2rad (x)) returns (s / s [-1]) * ms = sinespace () print (s) plt.plot (s, np.ones_like (s), 'ro') plt. Show ()

Note, for a maximum of 30, the space is similar to the linear space. The reason for this is that it is linear with theta for sin (theta) small theta (and when theta In radians, theta ~ = sin (theta) ). To show "signage", I've plotted it to 90 degrees to make it more clear.

Enter image details here


No comments:

Post a Comment