1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Rotate an array

  1. Apr 30, 2015 #1
    Rotate an array
    hi everyone

    I'm hoping someone maybe able to help me/ point me in the right direction with the rotation of data from an array. I'll try to keep it short but my maths skills are seriously not good due to my old age and inexperience. I maybe approaching it from the wrong angle and punching well above my weight. I'm pretty good at addition and subtraction even though sometimes I get stuck on division. icon_wink.gif

    Here is a link to a spreadsheet I’m working on which hopefully will eventually end up in a program controlling a DAC for a ADSR

    http://imgur.com/nAPHS3j

    Column A represents a wave in voltage x being time y being voltage.
    It is irrelevant what shape this is for it might be a straight line ..etc. etc.
    What interests me is its entry and exit voltage which are normally 100
    I have found through a lot of trial and error if I use the charts on the right (Rotate Chart & Add to F Chart) I can look up values and determine a different entry and exit voltage by rotating the wave.
    So for example if I wanted a entry of 300 and an exit of 200. I would use the value in cell L5 for Rotate which is 3.3 and the value in cell L18 for the Add to F which is 150.
    Now normally with a problem like this I would code a kinda lookup 3 dimensional array to get these values. But the real DAC has a voltage number range of 0-4095 which would mean an array size of 4095 raised to power 3. I think …..which is to much data for the processor I am using to store.

    In this example I reduced it to 0-100 so I could see what is going on.

    So my question is in an ideal world I would enter a value for the entry point and enter a value for the exit point and there would be some sort of equation which could work out from those 2 values the Rotate number and hopefully the Add to F number.

    I've been stuck on this for a while hence the plea for help.

    I think i tried all the functions in excel and watch you tube videos on rotation . but most of the ones i understand involve an extension of reflection

    I'm not to interested in the distortion of the wave as I quiet like it (if that makes sense)


    thanks for reading
    thanking you in advance for any guidance you can give
     
  2. jcsd
  3. Apr 30, 2015 #2

    Merlin3189

    User Avatar
    Gold Member

    Your original function is y(t) and the new function is z(t),
    so you need a function f(t) so that z(t) = y(t)*f(t)

    If the initial entry and exit points are P and desired entry and exit points are Q
    then ##f(t)= \frac{Q}{P}##

    If the desired exit points are different, Q0 and QT,
    ## f(t) = \frac{1}{P} (Q_0+ (Q_T-Q_0)\frac{t}{T})##

    and if the initial entry and exit points are not equal, so P0 and PT, then the general function is
    ## f(t) = \frac{TQ_0 +(Q_T -Q_0)t}{TP_0 +(P_T - P_0)t}##

    The main snag with this method that I can see is, if you increase the value of the entry ot exit point and there are signal values above this level, then after scaling there could be signal points above your maximum 4096. Provided you are scaling down, or using maxima as entry and exit points, then it should work.
    I've not yet checked what happens if polarity changes, but I did not notice any issues where this would matter.

    E&OE because my maths is very poor as well!
     
  4. Apr 30, 2015 #3
    Thanks Merlin for your reply

    Now i'm gonna spend the next day or so trying to understand it. and implement it .........gulp

    thank you again


    I may well be back .........if that's ok
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Rotate an array
  1. Average of an array (Replies: 3)

Loading...