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 158519

Submitted on 7 Nov 2012

Incorrect

14Size
Leading solution size is 10.
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
 
%% test 1
A = [15 13 3];
y_correct = [15 0 3];
assert(isequal(your_fcn_name(A),y_correct))
filetext = fileread('your_fcn_name.m');
assert(isempty(strfind(filetext, 'for')),'for command is forbidden')
assert(isempty(strfind(filetext, 'while')),'while command is forbidden')
assert(isempty(strfind(filetext, 'find')),'find command is forbidden')
assert(isempty(strfind(filetext, 'ind2sub')),'ind2sub command is forbidden')
Error: Output argument "ans" (and maybe others) not assigned during call to "/users/msssystem11/your_fcn_name.m>your_fcn_name".
2
Fail
 
%% test 2
A = 13;
y_correct = 0;
assert(isequal(your_fcn_name(A),y_correct))
filetext = fileread('your_fcn_name.m');
assert(isempty(strfind(filetext, 'for')),'for command is forbidden')
assert(isempty(strfind(filetext, 'while')),'while command is forbidden')
assert(isempty(strfind(filetext, 'find')),'find command is forbidden')
assert(isempty(strfind(filetext, 'ind2sub')),'ind2sub command is forbidden')
Error: Output argument "ans" (and maybe others) not assigned during call to "/users/msssystem11/your_fcn_name.m>your_fcn_name".
3
Fail
 
%% test 3
A = [];
y_correct = [];
assert(isequal(your_fcn_name(A),y_correct))
filetext = fileread('your_fcn_name.m');
assert(isempty(strfind(filetext, 'for')),'for command is forbidden')
assert(isempty(strfind(filetext, 'while')),'while command is forbidden')
assert(isempty(strfind(filetext, 'find')),'find command is forbidden')
assert(isempty(strfind(filetext, 'ind2sub')),'ind2sub command is forbidden')
Error: Output argument "ans" (and maybe others) not assigned during call to "/users/msssystem11/your_fcn_name.m>your_fcn_name".
4
Fail
 
%% test 4
A = [13 0 13; 13 13 8; 13 25 2];
titi = [0 0 0 ; 0 0 8;0 25 2];
assert(isequal(your_fcn_name(A),titi))
filetext = fileread('your_fcn_name.m');
assert(isempty(strfind(filetext, 'for')),'for command is forbidden')
assert(isempty(strfind(filetext, 'while')),'while command is forbidden')
assert(isempty(strfind(filetext, 'find')),'find command is forbidden')
assert(isempty(strfind(filetext, 'ind2sub')),'ind2sub command is forbidden')
Error: Output argument "ans" (and maybe others) not assigned during call to "/users/msssystem11/your_fcn_name.m>your_fcn_name".
5
Fail
 
%% test 5 with a  multidimensional array
A=rand(10,10,10);
A(1,2,2)=13;
A(3,4,1)=13;
A(5,6,3)=13;
% what you cannot do but me I can ;) !
titi = A;
I=find(titi==13);
[u,v,w]=ind2sub(size(titi),I);
for ii = 1 : numel(u)
titi(u(ii),v(ii),w(ii))=0;
end
assert(isequal(your_fcn_name(A),titi))
filetext = fileread('your_fcn_name.m');
assert(isempty(strfind(filetext, 'for')),'for command is forbidden')
assert(isempty(strfind(filetext, 'while')),'while command is forbidden')
assert(isempty(strfind(filetext, 'find')),'find command is forbidden')
assert(isempty(strfind(filetext, 'ind2sub')),'ind2sub command is forbidden')
Error: Output argument "ans" (and maybe others) not assigned during call to "/users/msssystem11/your_fcn_name.m>your_fcn_name".
6
Fail
 
%% test 6 repmat !
A = repmat(13,89,17);
assert(isequal(your_fcn_name(A),repmat(0,89,17)))
filetext = fileread('your_fcn_name.m');
assert(isempty(strfind(filetext, 'for')),'for command is forbidden')
assert(isempty(strfind(filetext, 'while')),'while command is forbidden')
assert(isempty(strfind(filetext, 'find')),'find command is forbidden')
assert(isempty(strfind(filetext, 'ind2sub')),'ind2sub command is forbidden')
Error: Output argument "ans" (and maybe others) not assigned during call to "/users/msssystem11/your_fcn_name.m>your_fcn_name".
7
Fail
 
%% test 7 magic!
A= magic(5);
B =A;
B(3,3) = 0
assert(isequal(your_fcn_name(A),B))
filetext = fileread('your_fcn_name.m');
assert(isempty(strfind(filetext, 'for')),'for command is forbidden')
assert(isempty(strfind(filetext, 'while')),'while command is forbidden')
assert(isempty(strfind(filetext, 'find')),'find command is forbidden')
assert(isempty(strfind(filetext, 'ind2sub')),'ind2sub command is forbidden')
Error: Output argument "ans" (and maybe others) not assigned during call to "/users/msssystem11/your_fcn_name.m>your_fcn_name".
8
Fail
 
%% test 8 floating (maybe people will work with string recognition)
A= 13.3;
B = A;
assert(isequal(your_fcn_name(A),B))
Error: Output argument "ans" (and maybe others) not assigned during call to "/users/msssystem11/your_fcn_name.m>your_fcn_name".