Go Premium for a chance to win a PS4. Enter to Win

x
Solved

# Upscale integer array

Posted on 2013-05-23
Medium Priority
350 Views
Hello,
I have some acquisition data stared in the following  arrays:

const
cChannels = 6;
cMaxSampleDuration = 420;

var
MyIntegerArray: array[0..cChannels -1, 0..cMaxSampleDuration -1] of Integer;

As you can see from the screenshot, the first channel has range -4.000 up to 4.000 and the other have smaller range. how can upscale the other channels to be almost in equal range of the first channel ?

Thank you
0
Question by:chmichael
1 Comment

LVL 28

Accepted Solution

Sinisa Vuk earned 2000 total points
ID: 39192655
Is this similar question as you asked before? Do you have problem with my code?
http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_28126546.html

For this request - little modification:
``````var
MyIntegerArray: array[0..cChannels -1, 0..cMaxSampleDuration -1] of Integer;
MaxVal, Channel, Samples, MaxAmp: Integer;
...
MaxAmp := 4000;

for Channel := 0 to 6 -1 do
begin
//pre scale to get max
MaxVal := 0;
for Samples := 0 to cMaxSampleDuration -1 do
if Abs(MyIntegerArray[Channel, Samples])>MaxVal then MaxVal:=Abs(MyIntegerArray[Channel, Samples]);

//scaling
for Samples := 0 to cMaxSampleDuration -1 do
MyIntegerArray[Channel, Samples] := MulDiv(MyIntegerArray[Channel, Samples], MaxAmp, MaxVal);
end;
``````
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question