Cody

Problem 45409. MinMax mapping

Solution 2185681

Submitted on 1 Apr 2020 by Rafael Hernandez-Walls
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
x = [ 2 5 10]; y =[1, 1.375, 2]; assert(isequal(minmax_map(x,1,2),y))

2   Pass
x=[-5 3 -65 -55 34 555 3 2 0 -5]; y =[ 187.1 198.71 100 114.52 243.71 1000 198.71 197.26 194.35 187.1]; z=abs(minmax_map(x,100,1000)-y)<0.01 assert(all(z))

z = 1×10 logical array 1 1 1 1 1 1 1 1 1 1

3   Pass
x = magic(3); y =[24 3 18 9 15 21 12 27 6]; assert(isequal(minmax_map(x,3,27),y))

4   Pass
x = pascal(5); y =[-100 -100 -100 -100 -100 -100 -97.101 -94.203 -91.304 -88.406 -100 -94.203 -85.507 -73.913 -59.42 -100 -91.304 -73.913 -44.928 -1.4493 -100 -88.406 -59.42 -1.4493 100]; z=abs(minmax_map(x,-100,100)-y)<0.01 assert(all(z,'all'))

z = 5×5 logical array 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

5   Pass
x=eye(5); y=[55 5 5 5 5 5 55 5 5 5 5 5 55 5 5 5 5 5 55 5 5 5 5 5 55]; assert(isequal(minmax_map(x,5,55),y))

6   Pass
x=[4 -5 -55 -555 34; 34 34 34 -66 2]; y=[1.4745 1.4669 1.4244 1 1.5 1.5 1.5 1.5 1.4151 1.4728] z=abs(minmax_map(x,1,1.5)-y)<0.01 assert(all(z,'all'))

y = 1.4745 1.4669 1.4244 1.0000 1.5000 1.5000 1.5000 1.5000 1.4151 1.4728 z = 2×5 logical array 1 1 1 1 1 1 1 1 1 1