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 210125

Submitted on 27 Feb 2013

Incorrect

33Size
Leading solution size is 12.
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
 
%%
x = 1;
y =2;
y_correct = 2;
assert(isequal(round(your_fcn_name(x,y)),y_correct))
filetext = fileread('your_fcn_name.m');
assert(isempty(strfind(filetext, '*')),'sign * forbidden')
assert(isempty(strfind(filetext, 'mtimes')),'mtimes forbidden')
assert(isempty(strfind(filetext, 'cross')),'cross forbidden')
assert(isempty(strfind(filetext, 'prod')),'prod forbidden')
assert(isempty(strfind(filetext, 'cumprod')))
assert(isempty(strfind(filetext, 'times')))
assert(isempty(strfind(filetext, 'mldivide')))
assert(isempty(strfind(filetext, 'mrdivide')))
assert(isempty(strfind(filetext, '/')),'/ forbidden')
assert(isempty(strfind(filetext, '\')))
assert(isempty(strfind(filetext, '-')))
assert(isempty(strfind(filetext, '^')),'^ forbidden')
assert(isempty(strfind(filetext, 'dot')))
assert(isempty(strfind(filetext, '''')),'string forbidden')
Error: The variable "ans" is undefined.
2
Fail
 
%%
x = 8;
y =25;
y_correct = 200;
assert(isequal(round(your_fcn_name(x,y)),y_correct))
filetext = fileread('your_fcn_name.m');
assert(isempty(strfind(filetext, '*')))
assert(isempty(strfind(filetext, 'mtimes')))
assert(isempty(strfind(filetext, 'cross')))
assert(isempty(strfind(filetext, 'prod')))
assert(isempty(strfind(filetext, 'cumprod')))
assert(isempty(strfind(filetext, 'times')))
assert(isempty(strfind(filetext, 'dot')))
Error: The variable "ans" is undefined.
3
Fail
 
%%
x = 8;
y =0;
y_correct = 0;
assert(isequal(round(your_fcn_name(x,y)),y_correct))
filetext = fileread('your_fcn_name.m');
assert(isempty(strfind(filetext, '*')))
assert(isempty(strfind(filetext, 'mtimes')))
assert(isempty(strfind(filetext, 'cross')))
assert(isempty(strfind(filetext, 'prod')))
assert(isempty(strfind(filetext, 'cumprod')))
assert(isempty(strfind(filetext, 'times')))
assert(isempty(strfind(filetext, 'dot')))
Error: Output argument "ans" (and maybe others) not assigned during call to "/users/msssystem16/your_fcn_name.m>your_fcn_name".
4
Fail
 
%%
x = -148;
y =2865;
y_correct = -424020;
assert(isequal(round(your_fcn_name(x,y)),y_correct))
filetext = fileread('your_fcn_name.m');
assert(isempty(strfind(filetext, '*')))
assert(isempty(strfind(filetext, 'mtimes')))
assert(isempty(strfind(filetext, 'cross')))
assert(isempty(strfind(filetext, 'prod')))
assert(isempty(strfind(filetext, 'cumprod')))
assert(isempty(strfind(filetext, 'times')))
assert(isempty(strfind(filetext, 'dot')))
Error: Output argument "ans" (and maybe others) not assigned during call to "/users/msssystem16/your_fcn_name.m>your_fcn_name".
5
Fail
 
%% Test 5 : randi!!
x = randi([1 58]);
y =286.5;
y_correct = x*y;
assert(abs( your_fcn_name(x,y)-y_correct)<1e-9)
filetext = fileread('your_fcn_name.m');
assert(isempty(strfind(filetext, '*')))
assert(isempty(strfind(filetext, 'mtimes')))
assert(isempty(strfind(filetext, 'cross')))
assert(isempty(strfind(filetext, 'prod')))
assert(isempty(strfind(filetext, 'cumprod')))
assert(isempty(strfind(filetext, 'times')))
assert(isempty(strfind(filetext, 'dot')))
Error: The variable "ans" is undefined.
6
Fail
 
%% Test 6 : randi and pi !!
x = randi([14 580]);
y = -pi;
y_correct = x*y;
assert(abs( your_fcn_name(x,y)-y_correct)<1e-9)
filetext = fileread('your_fcn_name.m');
assert(isempty(strfind(filetext, '*')))
assert(isempty(strfind(filetext, 'mtimes')))
assert(isempty(strfind(filetext, 'cross')))
assert(isempty(strfind(filetext, 'prod')))
assert(isempty(strfind(filetext, 'cumprod')))
assert(isempty(strfind(filetext, 'times')))
assert(isempty(strfind(filetext, 'dot')))
assert(isempty(strfind(filetext, 'num2str')))
assert(isempty(strfind(filetext, 'int2str')))
assert(isempty(strfind(filetext, 'dec2bin')))
Error: Output argument "ans" (and maybe others) not assigned during call to "/users/msssystem16/your_fcn_name.m>your_fcn_name".