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

Learn moreOpportunities for recent engineering grads.

Apply TodayCorrect

24Size

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

Test

Code Input and Output

1

Pass

%% P = [1 0; 1 2]; m1 = eye(2); m2 = ones(2); M_correct = [1 0 0 0; 0 1 0 0; 1 0 1 1; 0 1 1 1]; assert(isequal(patchworkMatrix(P,m1,m2),M_correct))

ans = [2x2 double] [2x2 double] [2x2 double]

2

Pass

%% P = 2-eye(4); m1 = eye(2); m2 = ones(2); M_correct = [1 0 1 1 1 1 1 1; 0 1 1 1 1 1 1 1; 1 1 1 0 1 1 1 1; 1 1 0 1 1 1 1 1; 1 1 1 1 1 0 1 1; 1 1 1 1 0 1 1 1; 1 1 1 1 1 1 1 0; 1 1 1 1 1 1 0 1]; assert(isequal(patchworkMatrix(P,m1,m2),M_correct))

ans = [2x2 double] [2x2 double] [2x2 double]

3

Pass

%% P = [2 3 2 3]; m1 = 1; m2 = 2; m3 = 3; M_correct = [2 3 2 3]; assert(isequal(patchworkMatrix(P,m1,m2,m3),M_correct))

ans = [0] [1] [2] [3]

4

Pass

%% P = [6 5; 4 3; 2 1]; m1 = rand(2,3); m2 = rand(2,3); m3 = rand(2,3); m4 = rand(2,3); m5 = rand(2,3); m6 = rand(2,3); M_correct = [m6 m5; m4 m3; m2 m1]; assert(isequal(patchworkMatrix(P,m1,m2,m3,m4,m5,m6),M_correct))

ans = Columns 1 through 6 [2x3 double] [2x3 double] [2x3 double] [2x3 double] [2x3 double] [2x3 double] Column 7 [2x3 double]

5

Pass

%% P = zeros(2); m1 = rand(3,2); m2 = rand(3,2); m3 = rand(3,2); m4 = rand(3,2); m5 = rand(3,2); m6 = rand(3,2); M_correct = zeros(6,4); assert(isequal(patchworkMatrix(P,m1,m2,m3,m4,m5,m6),M_correct))

ans = Columns 1 through 6 [3x2 double] [3x2 double] [3x2 double] [3x2 double] [3x2 double] [3x2 double] Column 7 [3x2 double]

6

Pass

%% P = []; m = cell(100); assert(isempty(patchworkMatrix(P,m{:})))

ans = Columns 1 through 16 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 17 through 32 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 33 through 48 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 49 through 64 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 65 through 80 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 81 through 96 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 97 through 112 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 113 through 128 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 129 through 144 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 145 through 160 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 161 through 176 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 177 through 192 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 193 through 208 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 209 through 224 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 225 through 240 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 241 through 256 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 257 through 272 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 273 through 288 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 289 through 304 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 305 through 320 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 321 through 336 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 337 through 352 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 353 through 368 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 369 through 384 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 385 through 400 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 401 through 416 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 417 through 432 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 433 through 448 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 449 through 464 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 465 through 480 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 481 through 496 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 497 through 512 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 513 through 528 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 529 through 544 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 545 through 560 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 561 through 576 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 577 through 592 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 593 through 608 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 609 through 624 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 625 through 640 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 641 through 656 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 657 through 672 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 673 through 688 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 689 through 704 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 705 through 720 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 721 through 736 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 737 through 752 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 753 through 768 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 769 through 784 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 785 through 800 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 801 through 816 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 817 through 832 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 833 through 848 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 849 through 864 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 865 through 880 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 881 through 896 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 897 through 912 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 913 through 928 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 929 through 944 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 945 through 960 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 961 through 976 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 977 through 992 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 993 through 1008 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 1009 through 1024 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 1025 through 1040 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 1041 through 1056 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 1057 through 1072 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 1073 through 1088 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 1089 through 1104 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 1105 through 1120 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 1121 through 1136 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 1137 through 1152 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 1153 through 1168 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 1169 through 1184 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 1185 through 1200 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 1201 through 1216 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 1217 through 1232 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 1233 through 1248 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 1249 through 1264 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 1265 through 1280 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Columns 1281 through 1296 [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Colum...