How to match ranges of values ​​in MATLAB

I hope there is a MATLAB function similar to this Arduino function: http://arduino.cc/en/Reference/map

Basically, I have a temporary variable with 67 data points in the range from 0 to 1.15, and I want to match this value from 0 to 100% (for example, 101 data points). In Arduino, which will look something like this:

map(value, fromLow, fromHigh, toLow, toHigh) 

I can use interp1 in MATLAB to get 101 data points, but I just get 101 data points between 0 and 1.15. I know that I can simply multiply each value by 100 / 1.15, but this is inaccurate. Is there a more elegant way to do this in MATLAB, which I skip?

(This post looked encouraging, but it's not what I'm looking for: Map function in MATLAB? )

thanks

+4
source share
3 answers

If you have a neural network toolkit, you can try mapminmax . By default, the function displays the interval between [-1 1] and receives input boundaries from the data. But I believe that populating the settings structure with your values, and then calling mapminmax should help.

0
source

you can use linspace for example

 linspace(0,1.15,101) 

will be evenly distributed over 101 points between the limits 0 and 1.15.

+1
source

My FEX maptorange application can do just that. It takes the initial value (s), the range from which they come, and the range into which they should be mapped, and returns the associated value (s). In your example, this would be:

 maptorange(values, [0 1.15], [0 100]); 

(This assumes a linear mapping. The script can also be displayed along an exponential function.)

To go from 67 to 101 values, you really need interpolation. This can be done before or after matching.

0
source

Source: https://habr.com/ru/post/1491215/


All Articles