Rotating an Array: Seeking Help with Maths Skills

In summary, the conversation discusses the rotation of data from an array and how to determine different entry and exit voltages by using the charts on the right. The main issue is the large amount of data that needs to be stored for the DAC and the solution proposed involves using a function to scale down the values. The conversation also mentions the potential issue of signal points exceeding the maximum value of 4096, but this can be resolved by scaling down or using maximum values as entry and exit points. The speaker expresses gratitude for the help and mentions the possibility of returning for further assistance.
  • #1
MM2758
5
0
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
 
Mathematics news on Phys.org
  • #2
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!
 
  • Like
Likes MM2758
  • #3
Thanks Merlin for your reply

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

thank you againI may well be back ...if that's ok
 

1. How do I rotate an array?

To rotate an array, you can use a simple mathematical formula where you take the index of the current element and add the number of rotations you want to perform. Then, subtract the length of the array from this value and use the result as the new index. This way, you can shift the elements in the array to the desired position.

2. How do I determine the number of rotations to perform?

The number of rotations to perform can be determined by the user or can be specified in the problem statement. If it is not specified, you can use the length of the array as a reference point. For example, if you want to rotate an array by 3 positions, but the length of the array is 5, you can perform 3 modulo 5 (3%5) rotations, which will result in the same array.

3. Can I rotate an array in both directions?

Yes, you can rotate an array in both clockwise and counterclockwise directions. The direction of rotation can be determined by the user or specified in the problem statement.

4. How do I handle edge cases, such as an empty array or a single element array?

In case of an empty array, there is nothing to rotate and hence, the resulting array will also be empty. For a single element array, there is only one possible rotation, which will result in the same array. It is important to handle these edge cases to avoid errors or unexpected results.

5. Is there a more efficient way to rotate an array?

Yes, there are multiple ways to rotate an array, and the most efficient approach may vary depending on the size of the array and the number of rotations. One possible approach is to use a temporary array to store the rotated elements and then copy them back to the original array. Another approach is to use reverse rotations, where you reverse the entire array first and then reverse the two subarrays created by the desired number of rotations. This approach can be more efficient for a large number of rotations.

Similar threads

Replies
4
Views
679
  • Programming and Computer Science
Replies
17
Views
2K
Replies
11
Views
1K
  • Electrical Engineering
Replies
10
Views
1K
  • General Math
Replies
7
Views
3K
  • Atomic and Condensed Matter
Replies
0
Views
386
Replies
2
Views
971
Replies
19
Views
1K
Replies
9
Views
2K
  • Programming and Computer Science
Replies
3
Views
2K
Back
Top