LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert array to 0:144

Solved!
Go to solution

Hello,

 

I have a 2D matrix like these: 

-1,0,4,-1

8,-3,8,-2

4,2,0,8

2,1,2,5

 

I would like to convert this array to another array which the maximum value (8) to be 144, and the minimum value (-3) to be 0.

and the other values with the same sequence,

simply i can convert the positive values, but I don't know how to convert the negative values. Like the attached vi

can you help!

0 Kudos
Message 1 of 2
(829 Views)
Solution
Accepted by topic author BaJa_2020

Hi BaJa,

 


@BaJa_2020 wrote:

I would like to convert this array to another array which the maximum value (8) to be 144, and the minimum value (-3) to be 0.

and the other values with the same sequence,


What "same sequence" are you talking about?

 

I guess you want to apply a (linear?) scaling to those values in the array: just do so!

The math behind that scaling is rather simple: when you have fnished school then you should know how to do that!

 

 

scaled_value := (unscaled_value - unscaled_min) * (scaled_max - scaled_min)/(unscaled_max - unscaled_min) + scaled_min

As most (basic) LabVIEW functions are polymorphic you can directly scale the whole array…

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 2
(825 Views)