functions about matrix on MatLab

profileA-Long
Hw1_template.zip

gps2d.m

%% % Solve for the 2D coordinate of P as a problem of linear system % % The parameters received are: % - a (2 x 1): 2D coordinate of point A % - b (2 x 1): 2D coordinate of point B % - c (2 x 1): 2D coordinate of point C % - ra (1 x 1): distance from A to P % - rb (1 x 1): distance from B to P % - rc (1 x 1): distance from C to P % % The function should return % - p (2 x 1): 2D coordinate of P function p = gps2d(a, b, c, ra, rb, rc) %%%% YOUR CODE STARTS HERE end

__MACOSX/._gps2d.m

gps3d.m

%% % Solve for the 3D coordinate of P as a problem of linear system % % The parameters received are: % - a (3 x 1): 3D coordinate of point A % - b (3 x 1): 3D coordinate of point B % - c (3 x 1): 3D coordinate of point C % - d (3 x 1): 3D coordinate of point D % - ra (1 x 1): distance from A to P % - rb (1 x 1): distance from B to P % - rc (1 x 1): distance from C to P % - rd (1 x 1): distance from D to P % % The function should return % - p (3 x 1): 3D coordinate of P function p = gps3d(a, b, c, d, ra, rb, rc, rd) %%%% YOUR CODE STARTS HERE end

__MACOSX/._gps3d.m

interchange.m

%% % Swap row i and row j of a matrix % % The parameters received are: % - A (m x n): a rectangular matrix % - i (1 x 1) % - j (1 x 1) % % The function should return % - B (m x n): the resulting rectangular matrix function B = interchange(A, i, j) %%%% YOUR CODE STARTS HERE end

__MACOSX/._interchange.m

my_rref.m

%% % Computes the reduced row echelon form of a matrix % % The parameters received are: % - A (m x n): a rectangular matrix % % The function should return % - B (m x n): the reduce row echelon form of A function B = my_rref(A) %%%% YOUR CODE STARTS HERE end

__MACOSX/._my_rref.m

replacement.m

%% % Add the result of a scalar times row j to row i of a matrix % % The parameters received are: % - A (m x n): a rectangular matrix % - i (1 x 1) % - j (1 x 1) % - s (1 x 1): a scalar % % The function should return % - B (m x n): the resulting rectangular matrix function B = replacement(A, i, j, s) %%%% YOUR CODE STARTS HERE end

__MACOSX/._replacement.m

scaling.m

%% % Multiply all entries in row i of a matrix by a scalar % % The parameters received are: % - A (m x n): a rectangular matrix % - i (1 x 1) % - s (1 x 1): a scalar % % The function should return % - B (m x n): the resulting rectangular matrix function B = scaling(A, i, s) %%%% YOUR CODE STARTS HERE end

__MACOSX/._scaling.m

solve.m

%% % Solve for the linear system Ax = b % % The parameters received are: % - A (m x n): a rectangular matrix % - b (m x 1): right hand side of a linear system % % The function should return % - x (n x 1): solution vector [x_1, x_2, ..., x_n] function x = solve(A, b) augmented_matrix = [A b]; % you can change it to rref if your my_rref does not work R = my_rref(augmented_matrix); x = R(:, end); end

__MACOSX/._solve.m