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 179014

Submitted on 18 Dec 2012 by @bmtran

Correct

140Size
Leading solution size is 70.
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
Pass
 
%%
L1 =  [0 0;
       2 2];
L2 =  [0 1;
       2 1];
[L3,L4] = cross2kiss(L1,L2);
L3c = [0 0;
       1 1;
       2 1]
L4c = [0 1;
       1 1;
       2 2]
assert(isequal(L3,L3c))
assert(isequal(L4,L4c))
L3c =
     0     0
     1     1
     2     1
L4c =
     0     1
     1     1
     2     2
2
Pass
 
%%
L1 =  [-2 -1;
        2  1];
L2 =  [-1  1;
        1 -1];
[L3,L4] = cross2kiss(L1,L2);
L3c =  [-2 -1;
         0  0;
         1 -1];
L4c =  [-1  1;
         0  0;
         2  1];
assert(isequal(L3,L3c))
assert(isequal(L4,L4c))

                    
3
Pass
 
%%
L1 =  [ 5  5;
        8 -4];
L2 =  [ 5 -2;
        9  0];
[L3,L4] = cross2kiss(L1,L2);
L3c =  [ 5 -2;
         7 -1;
         8 -4];
L4c =  [ 5  5;
         7 -1;
         9  0];
assert(isequal(L3,L3c))
assert(isequal(L4,L4c))