Cody

# Problem 2009. Insert certain elements into a vector.

Solution 357825

Submitted on 22 Nov 2013 by James
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
%% v = 1:5; u = [2 4]; w = [0 -1]; y = insert_some(v,w,u); y_correct = [1 0 2 3 -1 4 5]; assert(isequal(y,y_correct)) filetext = fileread('insert_some.m'); assert(isempty(strfind(filetext, 'regexp')),'regexp* command is forbidden'); assert(isempty(strfind(filetext, 'eval')),'eval* command is forbidden'); assert(isempty(strfind(filetext, 'inline')),'inline command is forbidden');

temp = 2 5

2   Pass
%% v = 1:100; u = 1:100; w = 1:100; y = insert_some(v,w,u); y_correct = reshape(repmat(1:100,2,1),1,[]); assert(isequal(y,y_correct))

temp = Columns 1 through 16 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 Columns 17 through 32 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 Columns 33 through 48 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 Columns 49 through 64 97 99 101 103 105 107 109 111 113 115 117 119 121 123 125 127 Columns 65 through 80 129 131 133 135 137 139 141 143 145 147 149 151 153 155 157 159 Columns 81 through 96 161 163 165 167 169 171 173 175 177 179 181 183 185 187 189 191 Columns 97 through 100 193 195 197 199

3   Pass
%% v = 0:99; u = 11:10:101; w = repmat(nan,1,10); y = insert_some(v,w,u); y_correct = reshape([reshape(v,10,[]);repmat(nan,1,10)],1,[]); assert(isequaln(y,y_correct))

temp = 11 22 33 44 55 66 77 88 99 110

4   Pass
%% v = repmat(1:2,1,100); w = repmat(3,1,100); u = 3:2:201; y = insert_some(v,w,u); y_correct = repmat(1:3,1,100); assert(isequaln(y,y_correct))

temp = Columns 1 through 16 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 Columns 17 through 32 51 54 57 60 63 66 69 72 75 78 81 84 87 90 93 96 Columns 33 through 48 99 102 105 108 111 114 117 120 123 126 129 132 135 138 141 144 Columns 49 through 64 147 150 153 156 159 162 165 168 171 174 177 180 183 186 189 192 Columns 65 through 80 195 198 201 204 207 210 213 216 219 222 225 228 231 234 237 240 Columns 81 through 96 243 246 249 252 255 258 261 264 267 270 273 276 279 282 285 288 Columns 97 through 100 291 294 297 300