Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Solution 218192

Submitted on 17 Mar 2013

Incorrect

26Size
Leading solution size is 17.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Fail
 
%% simple test
x = [-2 -10 5 10];
a = 0;  b = 1;
assert(isequal(rescale_vector(x,a,b),[0.4 0 0.75 1]))
Error: Output argument "y" (and maybe others) not assigned during call to "/users/msssystem6/rescale_vector.m>rescale_vector".
2
Fail
 
%% inverse test
x = [-2 -10 5 10];
a = 1;  b = 0;
assert(isequal(rescale_vector(x,a,b),[0.6 1 0.25 0]))
Error: Output argument "y" (and maybe others) not assigned during call to "/users/msssystem6/rescale_vector.m>rescale_vector".
3
Fail
 
%% extrem positive
x = rand(10,1);
a = realmin;  b = realmax/1e2;
y = rescale_vector(x,a,b)
assert(min(y)==realmin & max(y)==b)
Error: Output argument "y" (and maybe others) not assigned during call to "/users/msssystem6/rescale_vector.m>rescale_vector".
4
Fail
 
%% extrem
x = diag(pascal(10));
a = -realmax/2; b = realmax/2;
y = rescale_vector(x,a,b);
assert(min(y)==a && max(y)==b)
Error: Output argument "y" (and maybe others) not assigned during call to "/users/msssystem6/rescale_vector.m>rescale_vector".