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

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Solution 145435

Submitted on 8 Oct 2012 by Robert Canfield

Correct

62Size
Leading solution size is 32.
`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

```%%
A = [0 2; 1 3];
b = [4; 2];
Ab = [1 3 2; 0 2 4];
assert(isequal(PartialPivot(A,b,1),Ab))
```

2
Pass

```%%
A = [0 2 3; 4 6 7; 2, -3, 6];
b = [8; -3; 5];
Ab = [A([2 1 3],:), b([2 1 3])];
assert(isequal(PartialPivot(A,b,1),Ab))
```

3
Pass

```%%
A = [4 6 7; 0 2 3; 0, -6, 5/2];
b = [-3; 8; 13/2];
Ab = [A([1 3 2],:), b([1 3 2])];
assert(isequal(PartialPivot(A,b,2),Ab))
```

4
Pass

```%%
A = [0 2 5; 2 1 1; 3 1 0];
b = [1; 1; 2];
Ab = [A([3 2 1],:), b([3 2 1])];
assert(isequal(PartialPivot(A,b,1),Ab))
```

5
Pass

```%%
A = eye(4);
b = ones(4,1);
assert(isequal(PartialPivot(A,b,3),[A,b]))
```