Cody

# Problem 830. Fill a zeros matrix

Solution 2006902

Submitted on 7 Nov 2019 by Asif Newaz
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
value = -13; row = 2; col = 3; B = [0 0 0 0 0 -13]; assert(isequal(your_fcn_name(value,row,col),B)) filetext = fileread('your_fcn_name.m'); assert(isempty(strfind(filetext, 'zeros')),'zeros forbidden') assert(isempty(strfind(filetext, 'for')),'for forbidden') assert(isempty(strfind(filetext, 'repmat')),'repmat forbidden') assert(isempty(strfind(filetext, 'ones')),'ones forbidden') assert(isempty(strfind(filetext, 'while')),'while forbidden') assert(isempty(strfind(filetext, 'sparse')),'sparse forbidden')

ind = 6 y = 0.9190 0.7639 0.1114 0.1093 0.4903 -13.0000 y = 0 0 0 0 0 -13 B = 0 0 0 0 0 -13

2   Pass
value = 2012; row = [ 2 3 3 5 ]; col = [ 1 1 4 4 ]; C = [ 0 0 0 0 2012 0 0 0 2012 0 0 2012 0 0 0 0 0 0 0 2012]; assert(isequal(your_fcn_name(value,row,col),C)) filetext = fileread('your_fcn_name.m'); assert(isempty(strfind(filetext, 'zeros')),'zeros forbidden') assert(isempty(strfind(filetext, 'for')),'for forbidden') assert(isempty(strfind(filetext, 'repmat')),'repmat forbidden') assert(isempty(strfind(filetext, 'ones')),'ones forbidden') assert(isempty(strfind(filetext, 'while')),'while forbidden') assert(isempty(strfind(filetext, 'sparse')),'sparse forbidden')

ind = 2 3 18 20 y = 1.0e+03 * 0.0006 0.0002 0.0007 0.0010 2.0120 0.0003 0.0001 0.0003 2.0120 0.0002 0.0008 2.0120 0.0006 0.0007 0.0009 0.0004 0.0008 0.0005 0.0004 2.0120 y = 0 0 0 0 2012 0 0 0 2012 0 0 2012 0 0 0 0 0 0 0 2012 B = 0 0 0 0 2012 0 0 0 2012 0 0 2012 0 0 0 0 0 0 0 2012

3   Pass
I = [ 2 3 3 5 1 4 9 2 3 9 ]; J = [ 1 1 4 4 5 5 6 8 8 9 ]; assert(isequal(your_fcn_name(0,I,J),zeros(9))) filetext = fileread('your_fcn_name.m'); assert(isempty(strfind(filetext, 'zeros')),'zeros forbidden') assert(isempty(strfind(filetext, 'for')),'for forbidden') assert(isempty(strfind(filetext, 'repmat')),'repmat forbidden') assert(isempty(strfind(filetext, 'ones')),'ones forbidden') assert(isempty(strfind(filetext, 'while')),'while forbidden') assert(isempty(strfind(filetext, 'sparse')),'sparse forbidden')

ind = 2 3 30 32 37 40 54 65 66 81 y = 0.2625 0.4344 0.1401 0.7374 0 0.3487 0.6339 0.3556 0.0019 0 0.2596 0.0287 0.8952 0.4810 0.3770 0.1838 0 0.0064 0 0.9686 0.3653 0 0.5301 0.7205 0.7612 0 0.4605 0.5238 0.4203 0.1436 0.5476 0 0.6540 0.6641 0.3591 0.2197 0.7164 0.8033 0.8185 0 0.6363 0.7699 0.2056 0.7699 0.5389 0.6136 0.8933 0.4749 0.3625 0.4229 0.3897 0.8497 0.6168 0.4911 0.0917 0.6581 0.8774 0.8976 0.0844 0.5559 0.8870 0.5209 0.9371 0.2822 0.0805 0.5297 0.4807 0.0182 0.1990 0.2669 0.3654 0.5066 0.5776 0.2891 0.5365 0.5086 0.3103 0 0.6469 0.0816 0 y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 B = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

4   Pass
L = [ 2 3 3 5 1 4 9 2 3 9 ]; M = [ 1 1 4 4 5 5 6 8 8 9 ]; sol =[ 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 0 1 0 0 1 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1]; assert(isequal(your_fcn_name(1,L,M),sol)) filetext = fileread('your_fcn_name.m'); assert(isempty(strfind(filetext, 'zeros')),'zeros forbidden') assert(isempty(strfind(filetext, 'for')),'for forbidden') assert(isempty(strfind(filetext, 'repmat')),'repmat forbidden') assert(isempty(strfind(filetext, 'ones')),'ones forbidden') assert(isempty(strfind(filetext, 'while')),'while forbidden') assert(isempty(strfind(filetext, 'sparse')),'sparse forbidden')

ind = 2 3 30 32 37 40 54 65 66 81 y = 0.8996 0.9474 0.7435 0.2662 1.0000 0.1327 0.0607 0.8835 0.0348 1.0000 0.4172 0.4815 0.2873 0.9353 0.0898 0.1104 1.0000 0.0462 1.0000 0.9850 0.1640 1.0000 0.8483 0.5103 0.0476 1.0000 0.2355 0.2100 0.3451 0.1978 0.2634 1.0000 0.2776 0.0670 0.5702 0.1611 0.5917 0.3627 0.5342 1.0000 0.8917 0.0658 0.8767 0.0969 0.5101 0.6353 0.9130 0.3922 0.2047 0.5493 0.3329 0.3333 0.4729 0.5744 0.4212 0.1369 0.3211 0.6802 0.9744 0.1318 0.5002 0.8628 0.8197 0.6098 0.5792 0.3835 0.3852 0.5368 0.9767 0.0296 0.7926 0.1456 0.8083 0.9917 0.0482 0.2533 0.0509 1.0000 0.1090 0.8017 1.0000 y = 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 0 1 0 0 1 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 B = 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 0 1 0 0 1 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1

5   Pass
I = [ 2 3 3 5 1 4 9 2 3 9 ]; J = [ 1 1 4 4 5 5 6 8 8 9 ]; Z=[ 0 0 0 0 1999 0 0 0 0 1999 0 0 0 0 0 0 1999 0 1999 0 0 1999 0 0 0 1999 0 0 0 0 0 1999 0 0 0 0 0 0 0 1999 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1999 0 0 1999 ]; assert(isequal(your_fcn_name(1999,I,J),Z)) filetext = fileread('your_fcn_name.m'); assert(isempty(strfind(filetext, 'zeros')),'zeros forbidden') assert(isempty(strfind(filetext, 'for')),'for forbidden') assert(isempty(strfind(filetext, 'repmat')),'repmat forbidden') assert(isempty(strfind(filetext, 'ones')),'ones forbidden') assert(isempty(strfind(filetext, 'while')),'while forbidden') assert(isempty(strfind(filetext, 'sparse')),'sparse forbidden')

ind = 2 3 30 32 37 40 54 65 66 81 y = 1.0e+03 * 0.0005 0.0002 0.0010 0.0004 1.9990 0.0003 0.0010 0.0008 0.0009 1.9990 0.0002 0.0002 0.0005 0.0005 0.0003 0.0006 1.9990 0.0003 1.9990 0.0007 0.0002 1.9990 0.0008 0.0007 0.0002 1.9990 0.0006 0.0006 0.0004 0.0005 0.0007 1.9990 0.0007 0.0008 0.0007 0.0006 0.0004 0.0000 0.0009 1.9990 0.0005 0.0006 0.0002 0.0005 0.0010 0.0006 0.0009 0.0000 0.0000 0.0004 0.0004 0.0004 0.0001 0.0008 0.0002 0.0005 0.0003 0.0002 0.0003 0.0001 0.0001 0.0007 0.0004 0.0003 0.0004 0.0001 0.0008 0.0005 0.0003 0.0003 0.0008 0.0001 0.0002 0.0003 0.0002 0.0003 0.0009 1.9990 0.0002 0.0005 1.9990 y = 0 0 0 0 1999 0 0 0 0 1999 0 0 0 0 0 0 1999 0 1999 0 0 1999 0 0 0 1999 0 0 0 0 0 1999 0 0 0 0 0 0 0 1999 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1999 0 0 1999 B = 0 0 0 0 1999 0 0 0 0 1999 0 0 0 0 0 0 1999 0 1999 0 0 1999 0 0 0 1999 0 0 0 0 0 1999 0 0 0 0 0 0 0 1999 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1999 0 0 1999